[fix](analysis) Hide internal HAVING helper outputs - #67812
Merged
morrySnow merged 1 commit intoSep 11, 2026
Conversation
morrySnow
requested review from
924060929,
englefly and
starocean999
as code owners
September 10, 2026 11:48
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: 16909 ms |
Contributor
TPC-DS: Total hot run time: 81323 ms |
Contributor
ClickBench: Total hot run time: 14.59 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
### What problem does this PR solve? Problem Summary: When a scalar subquery selected one public expression while an aggregate appeared only in HAVING, fill-up analysis exposed the aggregate helper slot as a second output. The scalar-subquery validator then rejected a valid one-column query. This change restores the original projection output after HAVING or ORDER BY consumes helper slots, for both aggregate and non-aggregate branches. It preserves internal dependencies while keeping the public output contract unchanged. Tests cover a legal scalar subquery, an empty-result HAVING condition, and genuine multi-column rejection. ### Release note Fix false multi-column errors for scalar subqueries whose aggregate appears only in HAVING. ### Check List (For Author) - Test: Unit Test and Regression Test - Behavior changed: Yes. Internal helper slots no longer appear in query output. - Does this need documentation: No
Contributor
Author
|
run buildall |
morrySnow
force-pushed
the
fix/hide-having-helper-outputs
branch
from
September 11, 2026 06:15
5e4e781 to
b7066be
Compare
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 16772 ms |
Contributor
TPC-DS: Total hot run time: 81001 ms |
Contributor
ClickBench: Total hot run time: 14.59 s |
924060929
approved these changes
Sep 11, 2026
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:
A scalar subquery that exposes one expression can be rejected as returning two columns when an aggregate is used only by its
HAVINGclause.For example:
The fill-up analysis phase adds aggregate and missing-slot expressions to an internal project so that
HAVINGandORDER BYcan resolve them. In the aggregate path, it did not restore the original project afterwards. The helper aggregate therefore leaked into the public output, and scalar-subquery validation reportedFound 2.The rule now always adds a final project with the original output after
HAVINGandORDER BYconsume their helper slots. This keeps internal dependencies available during analysis while preserving the query's public output contract.Tests cover the valid scalar subquery, an empty result caused by
HAVING, and a genuine two-column scalar subquery that must still be rejected.Release note
Fix false multi-column errors for scalar subqueries whose aggregate appears only in
HAVING.Check List (For Author)