pitrou commented on code in PR #39785:
URL: https://github.com/apache/arrow/pull/39785#discussion_r1507479232
##########
cpp/src/gandiva/tests/in_expr_test.cc:
##########
@@ -208,16 +193,34 @@ TEST_F(TestIn, TestInDecimal) {
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0});
- std::shared_ptr<SelectionVector> selection_vector;
- status = SelectionVector::MakeInt16(num_records, pool_, &selection_vector);
+ {
+ std::shared_ptr<Filter> filter;
+ auto status = Filter::Make(schema, condition, TestConfiguration(),
&filter);
+ EXPECT_TRUE(status.ok());
+ std::shared_ptr<SelectionVector> selection_vector;
+ status = SelectionVector::MakeInt16(num_records, pool_, &selection_vector);
+ EXPECT_TRUE(status.ok());
+
+ // Evaluate expression
+ status = filter->Evaluate(*in_batch, selection_vector);
+ EXPECT_TRUE(status.ok());
+
+ // Validate results
+ EXPECT_ARROW_ARRAY_EQUALS(exp, selection_vector->ToArray());
+ }
+
+ std::shared_ptr<Filter> new_filter;
+ auto status = Filter::Make(schema, condition, TestConfiguration(),
&new_filter);
Review Comment:
Instead of copy-pasting almost the same code, I think you could have
something like:
```c++
// GH-39784: make sure that the filter expression works properly
// when fetched from cache.
for (int i = 0; i < 2; ++i) {
std::shared_ptr<Filter> filter;
auto status = Filter::Make(schema, condition, TestConfiguration(),
&filter);
EXPECT_TRUE(status.ok());
EXPECT_EQ(filter->GetBuiltFromCache(), i >= 1);
std::shared_ptr<SelectionVector> selection_vector;
status = SelectionVector::MakeInt16(num_records, pool_,
&selection_vector);
EXPECT_TRUE(status.ok());
// Evaluate expression
status = filter->Evaluate(*in_batch, selection_vector);
EXPECT_TRUE(status.ok());
// Validate results
EXPECT_ARROW_ARRAY_EQUALS(exp, selection_vector->ToArray());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]