MCPcopy Create free account
hub / github.com/apache/arrow / TEST_F

Function TEST_F

cpp/src/gandiva/tests/null_validity_test.cc:46–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46TEST_F(TestNullValidity, TestFunc) {
47 // schema for input fields
48 auto field0 = field("f0", int32());
49 auto field1 = field("f1", int32());
50 auto schema = arrow::schema({field0, field1});
51
52 // Build condition f0 + f1 < 10
53 auto node_f0 = TreeExprBuilder::MakeField(field0);
54 auto node_f1 = TreeExprBuilder::MakeField(field1);
55 auto sum_func =
56 TreeExprBuilder::MakeFunction("add", {node_f0, node_f1}, arrow::int32());
57 auto literal_10 = TreeExprBuilder::MakeLiteral((int32_t)10);
58 auto less_than_10 = TreeExprBuilder::MakeFunction("less_than", {sum_func, literal_10},
59 arrow::boolean());
60 auto condition = TreeExprBuilder::MakeCondition(less_than_10);
61
62 std::shared_ptr<Filter> filter;
63 auto status = Filter::Make(schema, condition, TestConfiguration(), &filter);
64 EXPECT_TRUE(status.ok());
65
66 // Create a row-batch with some sample data
67 int num_records = 5;
68
69 // Create an array without a validity buffer.
70 auto array0 = MakeArrowArrayInt32WithNullValidity({1, 2, 3, 4, 6});
71 auto array1 = MakeArrowArrayInt32({5, 9, 6, 17, 3}, {true, true, false, true, true});
72 // expected output (indices for which condition matches)
73 auto exp = MakeArrowArrayUint16({0, 4});
74
75 // prepare input record batch
76 auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0, array1});
77
78 std::shared_ptr<SelectionVector> selection_vector;
79 status = SelectionVector::MakeInt16(num_records, pool_, &selection_vector);
80 EXPECT_TRUE(status.ok());
81
82 // Evaluate expression
83 status = filter->Evaluate(*in_batch, selection_vector);
84 EXPECT_TRUE(status.ok());
85
86 // Validate results
87 EXPECT_ARROW_ARRAY_EQUALS(exp, selection_vector->ToArray());
88}
89
90TEST_F(TestNullValidity, TestIfElse) {
91 // schema for input fields

Callers

nothing calls this directly

Calls 10

TestConfigurationFunction · 0.85
fieldFunction · 0.50
schemaFunction · 0.50
MakeFunctionFunction · 0.50
MakeFunction · 0.50
okMethod · 0.45
EvaluateMethod · 0.45
ToArrayMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected