| 55 | } |
| 56 | |
| 57 | TEST_F(TestIn, TestInSimple) { |
| 58 | // schema for input fields |
| 59 | auto field0 = field("f0", int32()); |
| 60 | auto field1 = field("f1", int32()); |
| 61 | auto schema = arrow::schema({field0, field1}); |
| 62 | |
| 63 | // Build In f0 + f1 in (6, 11) |
| 64 | auto node_f0 = TreeExprBuilder::MakeField(field0); |
| 65 | auto node_f1 = TreeExprBuilder::MakeField(field1); |
| 66 | auto sum_func = |
| 67 | TreeExprBuilder::MakeFunction("add", {node_f0, node_f1}, arrow::int32()); |
| 68 | std::unordered_set<int32_t> in_constants({6, 11}); |
| 69 | auto in_expr = TreeExprBuilder::MakeInExpressionInt32(sum_func, in_constants); |
| 70 | auto condition = TreeExprBuilder::MakeCondition(in_expr); |
| 71 | |
| 72 | std::shared_ptr<Filter> filter; |
| 73 | auto status = Filter::Make(schema, condition, TestConfiguration(), &filter); |
| 74 | EXPECT_TRUE(status.ok()); |
| 75 | |
| 76 | // Create a row-batch with some sample data |
| 77 | int num_records = 5; |
| 78 | auto array0 = MakeArrowArrayInt32({1, 2, 3, 4, 6}, {true, true, true, false, true}); |
| 79 | auto array1 = MakeArrowArrayInt32({5, 9, 6, 17, 5}, {true, true, false, true, false}); |
| 80 | // expected output (indices for which condition matches) |
| 81 | auto exp = MakeArrowArrayUint16({0, 1}); |
| 82 | |
| 83 | // prepare input record batch |
| 84 | auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0, array1}); |
| 85 | |
| 86 | std::shared_ptr<SelectionVector> selection_vector; |
| 87 | status = SelectionVector::MakeInt16(num_records, pool_, &selection_vector); |
| 88 | EXPECT_TRUE(status.ok()); |
| 89 | |
| 90 | // Evaluate expression |
| 91 | status = filter->Evaluate(*in_batch, selection_vector); |
| 92 | EXPECT_TRUE(status.ok()); |
| 93 | |
| 94 | // Validate results |
| 95 | EXPECT_ARROW_ARRAY_EQUALS(exp, selection_vector->ToArray()); |
| 96 | } |
| 97 | |
| 98 | TEST_F(TestIn, TestInFloat) { |
| 99 | // schema for input fields |
nothing calls this directly
no test coverage detected