Baymine opened a new pull request, #66042:
URL: https://github.com/apache/doris/pull/66042
### 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.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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]