[improvement](parser) Assign query organization to a single owner - #67429
Open
morrySnow wants to merge 1 commit into
Open
[improvement](parser) Assign query organization to a single owner#67429morrySnow wants to merge 1 commit into
morrySnow wants to merge 1 commit into
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
16 tasks
morrySnow
force-pushed
the
codex/antlr4-query-organization-owner
branch
from
September 2, 2026 09:01
773c4ee to
1293889
Compare
### What problem does this PR solve? Issue Number: None Related PR: apache#67427 Problem Summary: The grammar allowed both querySpecification and its outer query to consume ORDER BY and LIMIT clauses, which introduced full-context ambiguity. Assign each clause group to exactly one owner according to ANSI mode and query level, preserve baseline first-error positions, and adapt the FE visitor to the new labeled contexts. LL_EXACT fallback and ambiguity for the target decisions drop to zero. Ordered SELECT end-to-end latency improves by 7.2% in legacy mode and 6.2% in ANSI mode; parser-only latency improves by 6.5% and 2.8% respectively. The plain SELECT control has no regression above the 3% threshold. ### Release note None ### Check List (For Author) - Test: Unit Test and manual performance/semantic validation - Maven parser and benchmark package: 238 tests passed - FE QueryOrganizationPlanTest and NereidsParserTest: 90 tests passed - Tracked SQL corpus: 4,610 files with identical parse/error signatures in both modes - Reused the original LL_EXACT profile, invalid-SQL matrix, and JMH comparison; the P2 functional patch has the same stable patch ID - Behavior changed: No - Does this need documentation: No
morrySnow
force-pushed
the
codex/antlr4-query-organization-owner
branch
from
September 2, 2026 16:32
1293889 to
0bf9111
Compare
Contributor
Author
|
run buildall |
morrySnow
marked this pull request as ready for review
September 2, 2026 16:36
morrySnow
requested review from
924060929,
englefly and
starocean999
as code owners
September 2, 2026 16:36
Contributor
TPC-H: Total hot run time: 16716 ms |
Contributor
TPC-DS: Total hot run time: 82716 ms |
Contributor
ClickBench: Total hot run time: 14.62 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?
Issue Number: None
Related PR: #67427
Problem Summary: The grammar allowed both
querySpecificationand its outerqueryto consumeORDER BYandLIMIT, so ANTLR repeatedly enteredqueryOrganizationand reported full-context ambiguities. This change gives every clause group one owner according to ANSI mode and query level, makes the rule structurally non-empty, preserves the existing accepted/rejected SQL matrix and first-error positions, and updates the FE plan builder for the labeled contexts.P1 (#67427) has now been merged into
master. This PR was rebased onto its merge commit (f054492cbb9) and now contains only the P2 functional commit (0bf9111810c). The obsolete stacked P1 commit was removed, so the PR is independently reviewable and mergeable against currentmaster. The P2 stable patch ID remains73da02c572e08918dc6306adbde23d30c7cdd39d, exactly matching the measured patch; the existing benchmark is reused and was not rerun.Benchmark
The original P2 benchmark is reused without rerunning it. The rebased P2 functional patch has the same stable patch ID (
73da02c572e08918dc6306adbde23d30c7cdd39d) as the measured commit. Lower latency is better. The target input isSELECT a, b, c FROM t WHERE a > 1 ORDER BY a, b DESC LIMIT 20 OFFSET 10; the control input has the same SELECT without query-organization clauses.5e0eadb13e9; parser jar SHA-256530f0ed45c4bac3a096373a1e932aae0025c603a6f905c3d975a2ad53bd0e7ca; benchmark jar SHA-2567543595b2a87f55b9b53538336cfedf55c13484302ffb487efcfb4fdd66b1c0b773c4ee1027; parser jar SHA-25665730a22a5262370a832bda7a04ae4b8e0de5c107be65c5ae80f95c711842f59; benchmark jar SHA-25647284ffd6779e9d534a19a682de5a4d468f83a62a98e048982807497f1f665b6fe/fe-sql-parser-benchmark/src/main/java/org/apache/doris/sqlparser/benchmark/QueryOrganizationBenchmark.javaOrdered SELECT target
The candidate change is calculated from the mean of C1 and C2 against B1. Values are us/op with JMH's 99.9% error estimate.
Plain SELECT control
No control-path latency regression exceeds the 3% threshold.
Allocation
The same artifacts were measured separately with
-prof gc. Timing under the profiler was noisy, so this table uses only normalized allocation.All allocation changes are below the 3% threshold.
Profile attribution
queryOrganization13,196 times and examined 49,902 lookahead tokens; SSB and Trino profiling reported 40 and 20 related ambiguities.querySpecificationandqueryOrganizationtarget decisions.Semantic differential
*.sqlfiles; manifest SHA-256567e209d57e5eaf6546ff03bf887437b8d647ed5f7ecb85bc657b987dd04be1069c811d0d80c52b40d8cd854e925ff4930aa6601c7d1e66541f2eb29f35db50afor every baseline/candidate outputRelease note
None
Check List (For Author)
Test
QueryOrganizationPlanTestandNereidsParserTest: 90 passed, 0 failuresBehavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)