github-actions[bot] commented on code in PR #69113:
URL: https://github.com/apache/doris/pull/69113#discussion_r4290096217
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java:
##########
@@ -140,6 +148,35 @@ public class ExpressionUtils {
// folding the conjunct). We restrict MAX_MARK_SLOT_COUNT to 4 to bound
this cost.
private static final int MAX_MARK_SLOT_COUNT = 4;
+ /**
+ * Date arithmetic can throw for values outside its valid range. Keep it
above a lower
+ * condition, join, limit, or CTE consumer so that those operators can
reject rows first.
+ * A date add/subtract with literal zero is an identity and remains safe
to push through.
+ */
+ public static boolean requiresDateArithmeticProtection(Expression
expression, Plan input) {
+ return expression.anyMatch(expr -> isUnsafeDateArithmetic((Expression)
expr))
+ && input.anyMatch(plan -> plan instanceof Filter || plan
instanceof Join || plan instanceof Limit
+ || plan instanceof LogicalCTEConsumer || plan
instanceof PhysicalCTEConsumer);
Review Comment:
[P2] Cover rejecting set and generate nodes in the protection check
This leaves the overflow fix incomplete for other row-discarding operators.
With `dt DATETIME(6)`, consider this reduced plan:
```text
Filter(d = '2020-02-05')
Project(CAST(WEEKS_ADD(dt,5) AS DATETIME(0)) AS d)
Except(Scan A(dt), Scan B(dt))
```
If A contains the maximum date and `2020-01-01`, and B contains the maximum
date, EXCEPT removes the overflowing row before the projection. This check
nevertheless returns false, so `PushDownFilterThroughProject` expands `d` and
`PushDownFilterThroughSetOperation` copies the arithmetic into the input scans.
`WEEKS_ADD` then throws on a row that should have been discarded. The
precision-lowering cast survives comparison simplification, so inverse date
rewriting does not avoid this path. `Generate(explode(arr))` with an empty
array has the same gap. Please protect these rejecting boundaries too and add
whole-rewriter regression coverage.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]