[feature](query) support max_visible_partition() syntax - #66187
Open
re20052 wants to merge 1 commit into
Open
Conversation
### What problem does this PR solve? Problem Summary: Support a new `max_visible_partition()` syntax after the table name so a query can be automatically pruned to the latest partition that has visible data, without hardcoding the partition name. - RANGE table: prune to the partition with the greatest range upper bound that has visible data. - UNPARTITIONED table: return the single partition if it has data, otherwise empty. - LIST table: no natural "latest" partition, return empty result. - Only OLAP table and materialized view are supported; other table types are rejected explicitly. ### Release note Support `max_visible_partition()` syntax to query the latest visible partition.
re20052
requested review from
924060929,
englefly,
morrySnow and
starocean999
as code owners
July 28, 2026 12:18
Contributor
Author
|
/review |
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 29463 ms |
Contributor
TPC-DS: Total hot run time: 176586 ms |
Contributor
ClickBench: Total hot run time: 24.92 s |
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.
What problem does this PR solve?
Problem Summary:
Support a new
max_visible_partition()syntax after the table name so a query can be automatically pruned to the latest partition that has visible data, without hardcoding the partition name.The common workaround
where pt = (select max(pt) from t)requires an extra sub-query, adding overhead in the Plan / Schedule / Execute phases. This syntax lets the engine resolve the target partition during Nereids binding and reuse the existing partition-pruning path, so the change is confined to FE and does not touch the execution layer.PartitionKey.compareTo, type-aware for numbers/dates, not by partition name).LogicalEmptyRelation) is built instead of throwing or falling back to a full scan.Release note
Support
max_visible_partition()syntax to query the latest visible partition.Check List (For Author)
Test
Regression suite:
regression-test/suites/nereids_syntax_p0/max_visible_partition.groovy, covering RANGE pruning, materialized view, View rejection, and UNPARTITIONED / LIST empty-result cases.Manual test on cluster
doris_ad_ttam_my3(tablead_stats_test.new_uid_sketch_creative_hourly): sub-query form 594ms / 4 fragments vsmax_visible_partition()27ms / 2 fragments.Behavior changed:
max_visible_partition()clause after the table name.MAX_VISIBLE_PARTITIONis a non-reserved keyword, so existing SQL is unaffected.Does this need documentation?
Check List (For Reviewer who merge this PR)