bkietz commented on code in PR #43761:
URL: https://github.com/apache/arrow/pull/43761#discussion_r1733164585
##########
cpp/src/arrow/compute/expression_test.cc:
##########
@@ -1643,6 +1719,44 @@ TEST(Expression, SimplifyThenExecute) {
AssertDatumsEqual(evaluated, simplified_evaluated, /*verbose=*/true);
}
+TEST(Expression, SimplifyIsInThenExecute) {
+ auto input = RecordBatchFromJSON(kBoringSchema, R"([
+ {"i64": 2, "i32": 5},
+ {"i64": 5, "i32": 6},
+ {"i64": 3, "i32": 6},
+ {"i64": 3, "i32": 5},
+ {"i64": 4, "i32": 5},
+ {"i64": 2, "i32": 7},
+ {"i64": 5, "i32": 5}
+ ])");
+
+ std::vector<Expression> guarantees{
+ greater(field_ref("i64"), literal(1)),
+ greater_equal(field_ref("i32"), literal(5)),
+ less_equal(field_ref("i64"), literal(5))};
+
+ for (const Expression& guarantee : guarantees) {
+ auto filter = call(
+ "is_in", {guarantee.call()->arguments[0]},
+ compute::SetLookupOptions{ArrayFromJSON(int32(), "[1,2,3]"), true});
+ ASSERT_OK_AND_ASSIGN(filter, filter.Bind(*kBoringSchema));
+ ASSERT_OK_AND_ASSIGN(auto simplified, SimplifyWithGuarantee(filter,
guarantee));
+
+ Datum evaluated, simplified_evaluated;
+ ExpectExecute(filter, input, &evaluated);
+ ExpectExecute(simplified, input, &simplified_evaluated);
+ if (simplified_evaluated.is_scalar()) {
+ ASSERT_EQ(evaluated.kind(), Datum::ARRAY);
+ ASSERT_EQ(simplified_evaluated.type()->id(), Type::BOOL);
+ BooleanBuilder builder;
+ ASSERT_OK(builder.AppendValues(
+ evaluated.length(),
simplified_evaluated.scalar_as<BooleanScalar>().value));
+ ASSERT_OK_AND_ASSIGN(simplified_evaluated, builder.Finish());
Review Comment:
```suggestion
ASSERT_OK_AND_ASSIGN(simplified_evaluated,
MakeArrayFromScalar(*simplified_evaluated.scalar(),
expected->length()));
```
##########
cpp/src/arrow/compute/expression_test.cc:
##########
@@ -1643,6 +1719,44 @@ TEST(Expression, SimplifyThenExecute) {
AssertDatumsEqual(evaluated, simplified_evaluated, /*verbose=*/true);
}
+TEST(Expression, SimplifyIsInThenExecute) {
Review Comment:
Thank you for adding this!
--
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]