Conversation
foxtail463
requested review from
924060929,
englefly,
morrySnow and
starocean999
as code owners
August 19, 2026 16:34
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 17495 ms |
Contributor
TPC-DS: Total hot run time: 84965 ms |
Contributor
ClickBench: Total hot run time: 14.95 s |
foxtail463
force-pushed
the
fix/compound-interval-arithmetic-operators
branch
from
August 20, 2026 03:55
9de4835 to
53c178f
Compare
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 17663 ms |
Contributor
TPC-DS: Total hot run time: 84750 ms |
Contributor
ClickBench: Total hot run time: 15.01 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
foxtail463
force-pushed
the
fix/compound-interval-arithmetic-operators
branch
from
August 20, 2026 10:40
53c178f to
4eac8b2
Compare
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 17443 ms |
Contributor
TPC-DS: Total hot run time: 83572 ms |
Contributor
ClickBench: Total hot run time: 14.59 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
Author
|
run cloud_p0 |
Contributor
Author
|
吐槽一下流水线 |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Collaborator
|
/review |
Contributor
There was a problem hiding this comment.
Request changes: one data-correctness issue remains in the compound-microsecond operator path.
Critical checkpoint conclusions:
- Goal and proof: Routing interval operators through
DATE_ADD/DATE_SUBfixes the invalid pluralized names, and the added analyzer tests prove representative compound plus simple-MICROSECOND bindings. The goal is not fully correct forTIMESTAMP_TZ: three compound-microsecond unit families bind but lose timezone type/semantics, as described inline. - Scope and clarity: The parser/binder change is small and focused. Reusing the existing datetime dispatcher is appropriate;
Interval.computeToSql()is consistent with the grammar and existing child renderers. - Parallel paths and conditions: Both legal addition orders and right-side subtraction were traced for all 20
Interval.TimeUnitvalues. Unit names, argument order, null propagation, FE folding, and BE registrations are otherwise aligned. The existing rejection of interval-first subtraction and other operators is unchanged. - Types and compatibility: Previously successful simple-unit operators still construct the same scalar functions with the same coercion. No new FE-BE symbol, persisted format, protocol field, or rolling-upgrade incompatibility is introduced. The accepted inline issue is the one type-family exception.
- Tests and results: Existing explicit
date_add/date_subregressions cover the downstream compound implementations, and the new FE tests cover parser-to-scalar binding, but timestamp-tz result type/output tests are missing for the newly enabled operator forms. Current CI reports COMPILE, FE UT, P0, external, nonconcurrent, and cloud regressions passing;check_coverage_feremains failing, so CI is not fully green. No local build or test was run in this review-only environment. - Concurrency and lifecycle: No shared mutable state, threading, locking, static initialization dependency, or special resource lifecycle is changed.
- Configuration, observability, transactions, and writes: No configuration, logging/metrics, transaction/persistence, data-write atomicity, or FE-to-BE variable propagation change is involved.
- Performance: The extra binder dispatch is analysis-time only and introduces no material hot-path cost or redundant runtime work.
- Additional user focus: No additional focus was supplied; the whole PR and all five changed paths were reviewed.
- Review completion: Two rounds converged. Both round-2 full reviewers and the separate risk-focused reviewer returned
NO_NEW_VALUABLE_FINDINGS; every candidate was independently verified, deduplicated, accepted, or dismissed. One inline issue is submitted.
morrySnow
approved these changes
Aug 25, 2026
morrySnow
pushed a commit
that referenced
this pull request
Sep 7, 2026
…age scans (#67182) ## Problem Summary: Monotonic-function predicates were only converted into bare-column ranges during partition pruning. Consequently, OLAP zone maps and Parquet/ORC min/max indexes could not use predicates such as date_trunc(dt, ...) = ..., date_format(dt, ...) = ..., or substring(col, ...) = ... to skip irrelevant storage ranges. ## Solution: - Reuse the monotonic predicate inference after CBO for OLAP scans, file scans, file TVFs, and storage-layer aggregate wrappers. - Preserve the original predicate and append only safety-checked necessary conditions, avoiding changes to query semantics, cardinality estimation, join planning, and MV matching. - Derive tighter two-sided ranges for supported prefix, date-format, and date rounding equalities. - Model adjacent bucket boundaries in date floor/ceil functions while conservatively excluding unsafe origins, timestamp-with-time-zone values, invalid boundaries, and non-ASCII prefix successors. - Prevent integer overflow when converting quarter periods into months. related pr: #66965 ## Performance Evaluation ### Setup - **Planner benchmark:** two independent runs measured both end-to-end SQL planning latency and time spent in `AddMonotonicFunctionPruningPredicates`. - **Execution benchmark:** A-B-A order with the same FE binary, BE process, metadata, data, and session settings. A temporary local switch changed only whether this post-processor ran. - **Data:** single-node, single-bucket OLAP table with 1,000,000 rows and 20 segments. Query, SQL, and condition caches were disabled, together with expression Zone Map pruning and count-on-index pushdown. - Positive cases used 5 warm-up and 20 measured runs; control cases used 3 warm-up and 10 measured runs. The BE binary was built with ASAN, so wall-clock speedups should be treated as directional results for this targeted workload rather than production guarantees. Profile pruning ratios are deterministic. ### Planner Overhead The table shows P50 ranges from the two runs. Percentages are relative to the baseline total planning P50. | Plan shape | Rule time and share of planning time | Additional total planning time | | --------------------------------------- | -----------------------------------: | -------------------------------------------: | | Scan without a filter | 0.81–1.06 μs (~0.02%) | Approximately zero (-1.29% to +0.20%, noise) | | Simple unsupported filter | 15.93–16.02 μs (0.31%–0.37%) | 13.6–34.7 μs (+0.32%–0.68%) | | One supported inference | 59.25–324.15 μs (1.85%–8.01%) | 119.2–793.7 μs (+5.07%–19.61%) | | Complex OR/UNION or multiple inferences | 160.09–263.87 μs (1.65%–5.82%) | 328.5–1058.6 μs (+5.86%–9.39%) | The supported cases covered `substring`, `year`, `date_format`, `date_trunc`, `date_floor`, `month_floor`, `month_ceil`, `to_date`, and `to_monday`. Ordinary single-scan queries incurred less than one millisecond of additional planning time. ### Execution Results | Scenario | Baseline P50 | PR P50 | Result | | ------------------------------------------------ | ---------------------------: | ---------------------------: | ----------------------------------------------------- | | Selective `date_trunc` | 1388.8 ms | 217.5 ms | 84.3% lower, 6.38× faster | | Selective `substring` | 2409.5 ms | 274.6 ms | 88.6% lower, 8.77× faster | | Mixed segment ranges with selective `date_trunc` | 1146–1310 ms | 707 ms | 38%–46% lower; midpoint: 42.4%, 1.74× faster | | Non-selective inferred year range | 1954.0 ms | 1934.7 ms | Approximately 1% difference; within measurement noise | | Unsupported predicate | Plans and profiles unchanged | Plans and profiles unchanged | No deterministic execution impact | For the two selective, well-clustered cases, Zone Map pruning eliminated 19 of 20 segments and reduced Profile `ScanRows` from 1,000,000 to 50,000. `ScanBytes` decreased from 7.85 MB to 588.93 KB for `date_trunc`, and from 16.73 MB to 1.02 MB for `substring`. In the mixed-layout case, every segment's min/max range covered the queried day, so no segment was pruned and `ScanBytes` remained unchanged. The inferred raw `dt` range still vector-filtered 950,000 rows before evaluating `date_trunc`, reducing expensive expression work without reducing storage I/O. ### Conclusion The optimization provides the largest benefit when the inferred range is selective and partition, segment, or row-group min/max ranges permit pruning. Even without storage pruning, the raw-column predicate may reduce expensive expression evaluation. Non-selective and unsupported predicates show no deterministic execution benefit, while planner overhead remains small and sub-millisecond for ordinary plans. --------- Co-authored-by: yangtao555 <yangtao555@jd.com>
morrySnow
pushed a commit
to morrySnow/incubator-doris
that referenced
this pull request
Nov 3, 2026
### What problem does this PR solve? Related PR: apache#66965 Problem Summary: 复合 interval 运算被绑定到不合法复数函数名,且 MICROSECOND 分派不全 Backport adaptation: Use branch-4.2 TimestampArithmetic for simple interval units and DATE_ADD/DATE_SUB binding for compound units and MICROSECOND. Preserve existing bind tests, object/complex type rejection and simple-unit plan representation; add compound interval and simple-unit coverage. CI follow-up: Restrict date-function binding to compound intervals and MICROSECOND. Preserve branch-4.2 TimestampArithmetic for simple units, including its plan representation and object/complex type validation; add unit coverage for all simple units and the BITMAP rejection. ### Release note 复合 interval 运算被绑定到不合法复数函数名,且 MICROSECOND 分派不全 ### Check List (For Author) - Test: Unit Test — org.apache.doris.nereids.rules.analysis.BindExpressionTest,org.apache.doris.nereids.trees.expressions.literal.IntervalTest,org.apache.doris.nereids.rules.expression.FoldConstantTest#testTimestampFold; FE Checkstyle passed. Cluster regression tests passed: shape_check/tpcds_sf100/load, shape_check/tpcds_sf1000/load, shape_check/tpcds_sf1000_constraints/load, nereids_syntax_p0/nereids_timestamp_arithmetic, shape_check/tpcds_sf1000/hint/query72, shape_check/tpcds_sf1000/shape/query72, shape_check/tpcds_sf1000_constraints/shape/query72_constraints, shape_check/tpcds_sf100/shape/query72, shape_check/tpcds_sf100/rf_prune/query72. - Behavior changed: Yes, fixes the behavior described above. - Does this need documentation: No (cherry picked from commit c899cea)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Route interval arithmetic operators through DATE_ADD and DATE_SUB, and add MICROSECOND handling to DatetimeFunctionBinder. This prevents compound intervals from binding to invalid pluralized function names while preserving simple interval behavior.
intro by #60347