Skip to content

Commit

Permalink
Flushing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OussamaSaoudi-db committed Oct 24, 2024
1 parent 4faff29 commit 984b615
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
19 changes: 19 additions & 0 deletions ffi/examples/visit-expression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,27 @@ target_compile_options(visit_expression PUBLIC)

target_compile_options(visit_expression PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-strict-prototypes)

# Get info on the OS and platform
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()

# Add the kernel expresion -> engine expression test
include(CTest)
set(ExprTestRunner "../../../tests/test_expression_visitor/run_test.sh")
set(ExprExpectedPath "../../../tests/test_expression_visitor/expected.txt")
add_test(NAME test_expression_visitor COMMAND ${ExprTestRunner} ${ExprExpectedPath})

if(LINUX)
add_test(NAME test_expression_visitor_leaks COMMAND valgrind
--error-exitcode=1
--tool=memcheck
--leak-check=full
--errors-for-leak-kinds=definite
--show-leak-kinds=definite ./visit_expression)
elseif(MACOSX)
add_test(NAME test_expression_visitor_leaks COMMAND leaks --atExit -- ./visit_expression)
endif()
30 changes: 12 additions & 18 deletions ffi/src/test_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub unsafe extern "C" fn get_testing_kernel_expression() -> Handle<SharedExpress

let nested_fields = vec![
StructField::new("a", DataType::INTEGER, false),
StructField::new("b", DataType::array(array_type), false),
StructField::new("b", array_type, false),
];
let nested_values = vec![Scalar::Integer(500), Scalar::Array(array_data.clone())];
let nested_struct = StructData::try_new(nested_fields.clone(), nested_values).unwrap();
Expand All @@ -53,21 +53,21 @@ pub unsafe extern "C" fn get_testing_kernel_expression() -> Handle<SharedExpress
Expr::literal(i32::MIN),
Expr::literal(i64::MAX),
Expr::literal(i64::MIN),
Expr::literal(Scalar::String("hello expressions".into())),
Expr::literal("hello expressions"),
Expr::literal(true),
Expr::literal(false),
Expr::literal(Scalar::Timestamp(50)),
Expr::literal(Scalar::TimestampNtz(100)),
Expr::literal(Scalar::Date(32)),
Expr::literal(Scalar::Binary(0x0000deadbeefcafeu64.to_be_bytes().to_vec())),
Scalar::Timestamp(50).into(),
Scalar::TimestampNtz(100).into(),
Scalar::Date(32).into(),
Scalar::Binary(0x0000deadbeefcafeu64.to_be_bytes().to_vec()).into(),
// Both the most and least significant u64 of the Decimal value will be 1
Expr::literal(Scalar::Decimal((1 << 64) + 1, 2, 3)),
Scalar::Decimal((1 << 64) + 1, 2, 3).into(),
Expr::null_literal(DataType::SHORT),
Expr::literal(Scalar::Struct(top_level_struct)),
Expr::literal(Scalar::Array(array_data)),
Scalar::Struct(top_level_struct).into(),
Scalar::Array(array_data).into(),
Expr::struct_from(vec![Expr::or_from(vec![
Expr::literal(Scalar::Integer(5)),
Expr::literal(Scalar::Long(20)),
Scalar::Integer(5).into(),
Scalar::Long(20).into(),
])]),
Expr::not(Expr::is_null(Expr::column("col"))),
];
Expand All @@ -88,13 +88,7 @@ pub unsafe extern "C" fn get_testing_kernel_expression() -> Handle<SharedExpress
BinaryOperator::Distinct,
]
.iter()
.map(|op| {
Expr::binary(
*op,
Expr::literal(Scalar::Integer(0)),
Expr::literal(Scalar::Long(0)),
)
}),
.map(|op| Expr::binary(*op, Scalar::Integer(0), Scalar::Long(0))),
);

Arc::new(Expr::and_from(sub_exprs)).into()
Expand Down
3 changes: 0 additions & 3 deletions kernel/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,6 @@ impl DataType {
_ => None,
}
}
pub fn array(array_type: ArrayType) -> Self {
DataType::Array(Box::new(array_type))
}
}

impl Display for DataType {
Expand Down

0 comments on commit 984b615

Please sign in to comment.