Skip to content

Commit

Permalink
Add ast cast test (rapidsai#16045)
Browse files Browse the repository at this point in the history
Add test for AST cast-to-float64

Resolves rapidsai#16023

Authors:
  - Paul Mattione (https://github.com/pmattione-nvidia)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Bradley Dice (https://github.com/bdice)

URL: rapidsai#16045
  • Loading branch information
pmattione-nvidia authored Jun 25, 2024
1 parent e4bd9e8 commit cdfb550
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cpp/tests/ast/transform_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ TEST_F(TransformTest, ColumnReference)
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
}

TEST_F(TransformTest, BasicAdditionDoubleCast)
{
auto c_0 = column_wrapper<double>{3, 20, 1, 50};
std::vector<__int128_t> data1{10, 7, 20, 0};
auto c_1 = cudf::test::fixed_point_column_wrapper<__int128_t>(
data1.begin(), data1.end(), numeric::scale_type{0});
auto table = cudf::table_view{{c_0, c_1}};
auto col_ref_0 = cudf::ast::column_reference(0);
auto col_ref_1 = cudf::ast::column_reference(1);
auto cast = cudf::ast::operation(cudf::ast::ast_operator::CAST_TO_FLOAT64, col_ref_1);
auto expression = cudf::ast::operation(cudf::ast::ast_operator::ADD, col_ref_0, cast);
auto expected = column_wrapper<double>{13, 27, 21, 50};
auto result = cudf::compute_column(table, expression);
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view(), verbosity);
}

TEST_F(TransformTest, Literal)
{
auto c_0 = column_wrapper<int32_t>{3, 20, 1, 50};
Expand Down

0 comments on commit cdfb550

Please sign in to comment.