bkietz commented on code in PR #14659:
URL: https://github.com/apache/arrow/pull/14659#discussion_r1024279433
##########
cpp/src/arrow/compute/exec/expression_test.cc:
##########
@@ -1098,6 +1122,12 @@ TEST(Expression, CanonicalizeAnd) {
// catches and_kleene even when it's a subexpression
ExpectCanonicalizesTo(is_valid(and_(b, true_)), is_valid(and_(true_, b)));
+
+ auto ts = field_ref("ts_ns");
+ using namespace arrow_literals;
+ ExpectCanonicalizesTo(add(ts, literal(5min)), add(literal(5min), ts));
+ ExpectCanonicalizesTo(add(add(ts, literal(5min)), add(literal(5min),
literal(5min))),
+ add(add(add(literal(5min), literal(5min)),
literal(5min)), ts));
Review Comment:
This is only checking the canonicalization pass, which (among other things)
flattens and refolds chains with literals first. This sets up an easy situation
for constant folding to do what you describe and eagerly evaluate constant
calls. The distinct passes are an implementation detail of the main entry point
`SimplifyWithGuarantee`, which might need to run cheap passes like constant
folding multiple times if more expensive passes like guarantee substitution
happen to yield a constant call.
--
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]