jacktengg commented on code in PR #70003:
URL: https://github.com/apache/doris/pull/70003#discussion_r4561317246
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRule.java:
##########
@@ -112,6 +113,23 @@ private static boolean couldRearrange(ComparisonPredicate
cmp) {
return false;
}
+ // The rule can move a date interval only if the date function keeps
the order of input values.
+ // It calls isMonotonic(null, null) because it has no input range
bounds.
+ // Calendar day addition can change UTC time order for TIMESTAMPTZ
values when the UTC offset changes.
+ //
+ // Example in America/New_York:
+ // ts = 2024-11-03 01:50:00-04:00
+ // cutoff = 2024-11-04 01:30:00-05:00
+ // days_add(ts, 1) < cutoff is false.
+ // ts < days_sub(cutoff, 1) is true.
+ // The subtraction selects the second 01:30 on November 3, with UTC
offset -05:00.
+ //
+ // The check keeps the original comparison if isMonotonic returns
false.
+ if (cmp.left() instanceof DateAddSubMonotonic
+ && !((DateAddSubMonotonic) cmp.left()).isMonotonic(null,
null)) {
Review Comment:
Handled in pr https://github.com/apache/doris/pull/70556.
--
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]