Baymine opened a new issue, #66041: URL: https://github.com/apache/doris/issues/66041
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version master / 4.0 ### What's Wrong? When querying a Hive view through the Nereids optimizer (with `enable_query_hive_views = true`), the outer query can fail with a "find no column" error whenever the view's declared column schema diverges from the slot names produced by the parsed view body. Root cause: in `BindRelation.bindRelation` for the `HMS_EXTERNAL_TABLE` case, the resulting `LogicalSubQueryAlias` is built with the 2-arg constructor, which leaves `columnAliases` empty. Its `computeOutput()` then falls back to the child (view-body) slot names instead of the view's declared schema, so an outer query that references the view columns by their declared names cannot resolve them. ### What You Expected? Querying a Hive view should resolve columns by the view's declared schema, regardless of the slot names used inside the view body. ### How to Reproduce? 1. Create a Hive view whose declared column names differ from the aliases in the view's `SELECT` body (e.g. the view is declared with columns `col1, col2` but its body is `SELECT 1 AS a, 2 AS b`). 2. With `enable_query_hive_views = true`, query the view from Doris: `SELECT col1, col2 FROM hms_catalog.db.view_name`. 3. Observe a "find no column" error. ### Anything Else? Fix: pass the view's declared schema (`HMSExternalTable.getFullSchema()`) as `columnAliases` to the 3-arg `LogicalSubQueryAlias` constructor. `computeOutput()` already honors `columnAliases` to rename the output slots, so the outer query then resolves view columns by the view definition. ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
