github-actions[bot] commented on code in PR #68641:
URL: https://github.com/apache/doris/pull/68641#discussion_r4132236427
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/FromSecondMonotonic.java:
##########
@@ -19,13 +19,15 @@
import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
+import org.apache.doris.nereids.util.DateUtils;
/** monotonicity for from_{xx}second */
public interface FromSecondMonotonic extends Monotonic {
@Override
default boolean isMonotonic(Literal lower, Literal upper) {
if (lower instanceof BigIntLiteral) {
- return ((BigIntLiteral) lower).getValue() >= 0;
+ return ((BigIntLiteral) lower).getValue() >= 0
+ &&
!DateUtils.hasFallbackTransition(DateUtils.getTimeZone());
Review Comment:
[P1] Resolve valid session time-zone aliases before checking monotonicity.
`SET time_zone='CST'` is accepted and Doris maps it to Asia/Shanghai, but
`DateUtils.getTimeZone()` calls `ZoneId.of(sessionValue)` without that alias
map. For a positive BIGINT range, this new call throws during
`OneRangePartitionEvaluator.computeMonotonicFunctionRange`;
`from_second(epoch)` on a RANGE-partitioned table therefore changes from
conservative, unpruned planning to a query error. The runtime-filter classifier
reaches the same call for joins on `from_second(epoch)`. Resolve with Doris's
alias mapping, or return false if resolution fails, and add a planner test for
CST.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateUtils.java:
##########
@@ -506,6 +507,25 @@ public static ZoneId getTimeZone() {
return
ZoneId.of(ConnectContext.get().getSessionVariable().getTimeZone());
}
+ /** Whether the zone's historical or recurring rules can move local time
backward. */
+ public static boolean hasFallbackTransition(ZoneId zoneId) {
+ ZoneRules rules = zoneId.getRules();
+ if (rules.isFixedOffset()) {
+ return false;
+ }
+ for (ZoneOffsetTransition transition : rules.getTransitions()) {
Review Comment:
[P2] Check fallbacks against bounded input ranges. Iterating every
historical transition makes `from_second` nonmonotonic for a July 2024
partition in `Asia/Shanghai`, solely because that zone fell back decades
earlier. For `from_second(epoch) >= '2024-07-20'` on a positive July 1-15 RANGE
partition, `OneRangePartitionEvaluator` now retains a partition it could
previously prune; `RuntimeFilterPruneClassifier` likewise emits no monotonicity
metadata for safe partitions. Use the supplied lower and upper epoch bounds to
check transitions in that interval, as `FromUnixtime` does, and remain
conservative for unknown or invalid bounds.
--
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]