[fix](fe) pass Hive view column aliases so outer query can resolve view columns#66042
Open
Baymine wants to merge 1 commit into
Open
[fix](fe) pass Hive view column aliases so outer query can resolve view columns#66042Baymine wants to merge 1 commit into
Baymine wants to merge 1 commit into
Conversation
…ew columns ### What problem does this PR solve? Issue Number: close apache#66041 Problem Summary: When querying a Hive view through the Nereids optimizer, the outer query could fail with a "find no column" error whenever the view's declared column schema diverged from the slot names produced by the parsed view body. The root cause is in `BindRelation.bindRelation` for the `HMS_EXTERNAL_TABLE` case: the resulting `LogicalSubQueryAlias` was built with the 2-arg constructor, which leaves `columnAliases` empty. Its `computeOutput()` then fell back to the child (view-body) slot names instead of the view's declared schema, so an outer query that referenced the view columns by their declared names could not resolve them. The fix passes the view's declared schema (from `HMSExternalTable.getFullSchema()`) as `columnAliases` to the 3-arg `LogicalSubQueryAlias` constructor. `computeOutput()` already honors `columnAliases` to rename the output slots, so the outer query now resolves view columns by the view definition. This is a hand-port of an internal fix; JD-only helpers (an internal auth context and a view-SQL transformer) were intentionally dropped. ### Release note Fixed a "find no column" error when querying certain Hive views whose declared column names differ from the view body slot names. ### Check List (For Author) - Test: Unit Test - Added `BindRelationTest.bindHiveViewPropagatesColumnAliases`: drives the real `BindRelation` rule over a spied `HMSExternalTable` view whose declared schema (`col1,col2`) deliberately differs from the view body slot names (`a,b`), and asserts the resulting `LogicalSubQueryAlias` carries the schema as `columnAliases` and that `computeOutput()` slot names equal `[col1,col2]`. - Ran `run-fe-ut.sh --run BindRelationTest`: 7 tests run, 0 failures, 0 errors, 0 skipped (locally green). - Behavior changed: Yes — Hive view output columns are now renamed to match the view's declared schema (previously kept the view-body slot names). - Does this need documentation: No
Baymine
requested review from
924060929,
englefly,
morrySnow and
starocean999
as code owners
July 25, 2026 08:51
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
3 tasks
Contributor
TPC-H: Total hot run time: 29083 ms |
Contributor
TPC-DS: Total hot run time: 177449 ms |
Contributor
ClickBench: Total hot run time: 24.99 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
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: close #66041
Problem Summary: When querying a Hive view through the Nereids optimizer, the
outer query could fail with a "find no column" error whenever the view's
declared column schema diverged from the slot names produced by the parsed
view body. The root cause is in
BindRelation.bindRelationfor theHMS_EXTERNAL_TABLEcase: the resultingLogicalSubQueryAliaswas builtwith the 2-arg constructor, which leaves
columnAliasesempty. ItscomputeOutput()then fell back to the child (view-body) slot names insteadof the view's declared schema, so an outer query that referenced the view
columns by their declared names could not resolve them.
The fix passes the view's declared schema (from
HMSExternalTable.getFullSchema())as
columnAliasesto the 3-argLogicalSubQueryAliasconstructor.computeOutput()already honorscolumnAliasesto rename the output slots,so the outer query now resolves view columns by the view definition.
This is a hand-port of an internal fix; JD-only helpers (an internal auth
context and a view-SQL transformer) were intentionally dropped.
Release note
Fixed a "find no column" error when querying certain Hive views whose declared column names differ from the view body slot names.
Check List (For Author)
BindRelationTest.bindHiveViewPropagatesColumnAliases: drives thereal
BindRelationrule over a spiedHMSExternalTableview whosedeclared schema (
col1,col2) deliberately differs from the view bodyslot names (
a,b), and asserts the resultingLogicalSubQueryAliascarries the schema as
columnAliasesand thatcomputeOutput()slotnames equal
[col1,col2].run-fe-ut.sh --run BindRelationTest: 7 tests run, 0 failures,0 errors, 0 skipped (locally green).
the view's declared schema (previously kept the view-body slot names).