From e82eb886612f77cb9b3cbaa2461e96a02b76de9e Mon Sep 17 00:00:00 2001 From: Yuan Date: Tue, 2 Feb 2021 20:32:00 +0800 Subject: [PATCH] [NSE-48] fix c++ unit tests (#60) * fix tests for smj Signed-off-by: Yuan Zhou * fixing unit tests with new api Signed-off-by: Yuan Zhou * fix outer join Signed-off-by: Yuan Zhou --- cpp/src/tests/arrow_compute_test_aggregate.cc | 33 ++++++++----- .../tests/arrow_compute_test_hashaggregate.cc | 33 ++++++++----- cpp/src/tests/arrow_compute_test_join.cc | 24 ++++++---- cpp/src/tests/arrow_compute_test_join_smj.cc | 37 +++++++++------ cpp/src/tests/arrow_compute_test_sort.cc | 47 ++++++++++++------- 5 files changed, 113 insertions(+), 61 deletions(-) diff --git a/cpp/src/tests/arrow_compute_test_aggregate.cc b/cpp/src/tests/arrow_compute_test_aggregate.cc index 725a50226..1a5799395 100644 --- a/cpp/src/tests/arrow_compute_test_aggregate.cc +++ b/cpp/src/tests/arrow_compute_test_aggregate.cc @@ -65,7 +65,8 @@ TEST(TestArrowCompute, AggregatewithMultipleBatchTest) { f_sum, f_count, f_sum, f_count, f_float, f_res, f_res, f_float, f_float, f_float}; ///////////////////// Calculation ////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> result_batch; std::vector input_data_string = {"[8, 10, 9, 20, 55, 42, 28, 32, 54, 70]", @@ -141,7 +142,8 @@ TEST(TestArrowCompute, GroupByAggregateWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -218,7 +220,8 @@ TEST(TestArrowCompute, GroupByAvgWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -284,7 +287,8 @@ TEST(TestArrowCompute, GroupByCountAllWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -352,7 +356,8 @@ TEST(TestArrowCompute, GroupByTwoAggregateWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -426,7 +431,8 @@ TEST(TestArrowCompute, GroupByTwoUtf8AggregateWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -490,7 +496,8 @@ TEST(TestArrowCompute, GroupByAggregateWithMultipleBatchOutputWoKeyTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -547,7 +554,8 @@ TEST(TestArrowCompute, StddevSampFinalTest) { std::vector> ret_types = {f_float}; ///////////////////// Calculation ////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> result_batch; std::vector input_data_string = { @@ -604,7 +612,8 @@ TEST(TestArrowCompute, GroupByStddevSampPartialWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -679,7 +688,8 @@ TEST(TestArrowCompute, GroupByStddevSampFinalWithMultipleBatchTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -748,7 +758,8 @@ TEST(TestArrowCompute, GroupbySumCountMergeTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; diff --git a/cpp/src/tests/arrow_compute_test_hashaggregate.cc b/cpp/src/tests/arrow_compute_test_hashaggregate.cc index 501d2b715..2294d4467 100644 --- a/cpp/src/tests/arrow_compute_test_hashaggregate.cc +++ b/cpp/src/tests/arrow_compute_test_hashaggregate.cc @@ -67,7 +67,8 @@ TEST(TestArrowCompute, GroupByHashAggregateTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -155,7 +156,8 @@ TEST(TestArrowCompute, GroupByHashAggregateTest2) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -243,7 +245,8 @@ TEST(TestArrowCompute, GroupByHashAggregateTest3) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -321,7 +324,8 @@ TEST(TestArrowCompute, GroupByHashAggregateWithStringTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -403,7 +407,8 @@ TEST(TestArrowCompute, GroupByHashAggregateWithProjectionTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -489,7 +494,8 @@ TEST(TestArrowCompute, GroupByHashAggregateWithCaseWhenTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -567,7 +573,8 @@ TEST(TestArrowCompute, GroupByHashAggregateWithNoKeyTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -649,7 +656,8 @@ TEST(TestArrowCompute, GroupByHashAggregateWithTwoStringTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -732,7 +740,8 @@ TEST(TestArrowCompute, GroupByHashAggregateWithProjectedKeyTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -815,7 +824,8 @@ TEST(TestArrowCompute, GroupByStddevSampPartialHashAggregateTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; @@ -904,7 +914,8 @@ TEST(TestArrowCompute, GroupByStddevSampFinalHashAggregateTest) { /////////////////////// Create Expression Evaluator //////////////////// std::shared_ptr expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, expr_vector, ret_types, &expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, expr_vector, ret_types, &expr, true)); std::shared_ptr input_batch; std::vector> output_batch_list; diff --git a/cpp/src/tests/arrow_compute_test_join.cc b/cpp/src/tests/arrow_compute_test_join.cc index 82cc524b7..ebf1cd500 100644 --- a/cpp/src/tests/arrow_compute_test_join.cc +++ b/cpp/src/tests/arrow_compute_test_join.cc @@ -69,7 +69,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingInnerJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -182,7 +183,8 @@ TEST(TestArrowComputeJoin, JoinTestWithTwoKeysUsingInnerJoin) { ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); @@ -288,7 +290,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingOuterJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); @@ -397,7 +400,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingAntiJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator(schema_table_0, {probeArrays_expr}, + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -503,7 +507,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingInnerJoinWithCondition) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); @@ -612,7 +617,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingAntiJoinWithCondition) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator(schema_table_0, {probeArrays_expr}, + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -715,7 +721,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingExistenceJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table1_f0, field("table1_exists", boolean()), table1_f1}, &expr_probe, true)); @@ -836,7 +843,8 @@ TEST(TestArrowComputeJoin, JoinTestUsingInnerJoinWithProjectedCondition) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); diff --git a/cpp/src/tests/arrow_compute_test_join_smj.cc b/cpp/src/tests/arrow_compute_test_join_smj.cc index c4888e38e..9b465d13f 100644 --- a/cpp/src/tests/arrow_compute_test_join_smj.cc +++ b/cpp/src/tests/arrow_compute_test_join_smj.cc @@ -64,7 +64,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingInnerJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -169,7 +170,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingOuterJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); @@ -180,7 +182,7 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingOuterJoin) { std::vector> table_0; std::vector> table_1; - std::vector input_data_string = {"[null, null, 2, 2, 3, 5, 7, 9, 11]", + std::vector input_data_string = {"[0, 0, 2, 2, 3, 5, 7, 9, 11]", "[null, null, 2, 2, 3, 5, 7, 9, 11]", "[null, null, 2, 2, 3, 5, 7, 9, 11]"}; MakeInputBatch(input_data_string, schema_table_0, &input_batch); @@ -191,7 +193,7 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingOuterJoin) { MakeInputBatch(input_data_string, schema_table_0, &input_batch); table_0.push_back(input_batch); - std::vector input_data_2_string = {"[null, 1, 2, 3, 4, 5, 6]", + std::vector input_data_2_string = {"[0, 1, 2, 3, 4, 5, 6]", "[null, 1, 2, 3, 4, 5, 6]"}; MakeInputBatch(input_data_2_string, schema_table_1, &input_batch); table_1.push_back(input_batch); @@ -205,9 +207,9 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingOuterJoin) { std::vector> expected_table; std::shared_ptr expected_result; std::vector expected_result_string = { - "[0, 0, null, 2, 2, 3, null, 5, null]", "[0, 0, null, 2, 2, 3, null, 5, null]", - "[0, 0, null, 2, 2, 3, null, 5, null]", "[0, 0, 1, 2, 2, 3, 4, 5, 6]", - "[0, 0, 1, 2, 2, 3, 4, 5, 6]"}; + "[0, 0, null, 2, 2, 3, null, 5, null]", "[null, null, null, 2, 2, 3, null, 5, null]", + "[null, null, null, 2, 2, 3, null, 5, null]", "[0, 0, 1, 2, 2, 3, 4, 5, 6]", + "[null, null, 1, 2, 2, 3, 4, 5, 6]"}; auto res_sch = arrow::schema({f_res, f_res, f_res, f_res, f_res}); MakeInputBatch(expected_result_string, res_sch, &expected_result); expected_table.push_back(expected_result); @@ -278,7 +280,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingAntiJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator(schema_table_0, {probeArrays_expr}, + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(),schema_table_0, {probeArrays_expr}, {table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -379,7 +382,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingSemiJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator(schema_table_0, {probeArrays_expr}, + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(),schema_table_0, {probeArrays_expr}, {table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -485,7 +489,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingSemiJoinWithCondition) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator(schema_table_0, {probeArrays_expr}, + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(),schema_table_0, {probeArrays_expr}, {table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -591,7 +596,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingInnerJoinWithCondition) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); @@ -700,7 +706,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestWithTwoKeysUsingInnerJoin) { ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}, &expr_probe, true)); @@ -809,7 +816,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingAntiJoinWithCondition) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator(schema_table_0, {probeArrays_expr}, + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(),schema_table_0, {probeArrays_expr}, {table1_f0, table1_f1}, &expr_probe, true)); std::shared_ptr input_batch; @@ -912,7 +920,8 @@ TEST(TestArrowComputeMergeJoin, JoinTestUsingExistenceJoin) { arrow::schema({table0_f0, table0_f1, table0_f2, table1_f0, table1_f1}); ///////////////////// Calculation ////////////////// std::shared_ptr expr_probe; - ASSERT_NOT_OK(CreateCodeGenerator( + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), schema_table_0, {probeArrays_expr}, {table1_f0, field("table1_exists", boolean()), table1_f1}, &expr_probe, true)); diff --git a/cpp/src/tests/arrow_compute_test_sort.cc b/cpp/src/tests/arrow_compute_test_sort.cc index dc3e54f88..d6d7413fc 100644 --- a/cpp/src/tests/arrow_compute_test_sort.cc +++ b/cpp/src/tests/arrow_compute_test_sort.cc @@ -60,7 +60,8 @@ TEST(TestArrowComputeSort, SortTestInPlaceNullsFirstAsc) { std::vector> ret_types = {f0}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -143,7 +144,8 @@ TEST(TestArrowComputeSort, SortTestInplaceNullsLastAsc) { std::vector> ret_types = {f0}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -226,7 +228,8 @@ TEST(TestArrowComputeSort, SortTestInplaceNullsFirstDesc) { std::vector> ret_types = {f0}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -309,7 +312,8 @@ TEST(TestArrowComputeSort, SortTestInplaceNullsLastDesc) { std::vector> ret_types = {f0}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -392,7 +396,8 @@ TEST(TestArrowComputeSort, SortTestInplaceAsc) { std::vector> ret_types = {f0}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -475,7 +480,8 @@ TEST(TestArrowComputeSort, SortTestInplaceDesc) { std::vector> ret_types = {f0}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -557,7 +563,8 @@ TEST(TestArrowComputeSort, SortTestOnekeyNullsFirstAsc) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -647,7 +654,8 @@ TEST(TestArrowComputeSort, SortTestOnekeyNullsLastAsc) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -735,7 +743,8 @@ TEST(TestArrowComputeSort, SortTestOnekeyNullsFirstDesc) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -823,7 +832,8 @@ TEST(TestArrowComputeSort, SortTestOnekeyNullsLastDesc) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -914,7 +924,8 @@ TEST(TestArrowComputeSort, SortTestOnekeyBooleanDesc) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -1007,7 +1018,8 @@ TEST(TestArrowComputeSort, SortTestOneKeyStr) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; std::vector> dummy_result_batches; @@ -1093,7 +1105,8 @@ TEST(TestArrowComputeSort, SortTestOneKeyWithProjection) { std::vector> ret_types = {f0, f1}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK(CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; std::vector> dummy_result_batches; @@ -1179,8 +1192,8 @@ TEST(TestArrowComputeSort, SortTestMultipleKeysNaN) { std::vector> ret_types = {f0, f1, f2, f3}; ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK( - CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list; @@ -1315,8 +1328,8 @@ TEST(TestArrowComputeSort, SortTestMultipleKeysWithProjection) { auto ret_schema = arrow::schema(ret_types); ///////////////////// Calculation ////////////////// std::shared_ptr sort_expr; - ASSERT_NOT_OK( - CreateCodeGenerator(sch, {sortArrays_expr}, ret_types, &sort_expr, true)); + arrow::compute::FunctionContext ctx; + ASSERT_NOT_OK(CreateCodeGenerator(ctx.memory_pool(), sch, {sortArrays_expr}, ret_types, &sort_expr, true)); std::shared_ptr input_batch; std::vector> input_batch_list;