amitvijapur commented on issue #21066:
URL: https://github.com/apache/datafusion/issues/21066#issuecomment-5784134371
I ran the test from the description against `main` at ee8344c today. The `No
field named base.name` error is gone: the outer projection now qualifies `name`
with `derived_projection`, since `rebase_derived_input_expr` in
`unparser/plan.rs` rewrites the outer expressions when the dialect requires a
derived table alias, and #25521 (merged today) makes the inner select emit
`sum("base"."salary") AS "sum(base.salary)"` so that reference resolves too.
The round trip still fails, but on a different check:
```
Error during planning: __common_expr_1 is a reserved DataFusion column name,
please use another name
```
`check_plan` in `sql/src/statement.rs` rejects any field whose name starts
with `__common_expr`, so the SQL that the unparser produces for an optimized
plan cannot be planned again by DataFusion. The emitted SQL itself is fine:
after a textual rename of `__common_expr_` the query plans and runs, for this
query and for CSE shapes without a CTE, under both `PostgreSqlDialect` and
`DefaultDialect`.
So the qualifier bug this issue is about is fixed, and what remains is a
choice between renaming reserved aliases in the unparser before emission or
narrowing `check_plan` to the top-level schema, which reopens the collision the
guard was added for (`test_reserved_column_name*` in `sql_integration.rs` pins
the current behaviour). That seems worth a maintainer's call before anyone
writes it, and probably a separate issue, since it is not specific to
PostgreSQL.
--
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]