Ritesh17rb opened a new issue, #27723:
URL: https://github.com/apache/datafusion/issues/27723
`ExprPlanner::plan_struct_literal(args, is_named_struct)` cannot distinguish
an explicit alias from a field name generated by SQL planning when a struct
mixes aliased and unnamed expressions.
These queries produce the same interleaved field-name/value arguments at the
planner hook:
```sql
SELECT struct(1 AS a, 2);
SELECT struct(1 AS a, 2 AS c1);
```
For both, `create_named_struct_expr` supplies `'a', 1, 'c1', 2`, with
`is_named_struct = true`. In Spark 4.2.0, the first query must have fields `a,
col2`, while the second must keep the explicit fields `a, c1`.
This makes a Spark ExprPlanner unable to assign Spark's one-based default
names without also changing valid explicit aliases. It also prevents retaining
an unaliased column's name in a mixed call such as `struct(1 AS x, a)`.
Could `parse_struct` preserve which names were explicit versus generated, or
provide the original expressions/aliases to the extension planner before
assigning DataFusion's default names? This does not require changing
DataFusion's existing default naming convention.
Reproduced with DataFusion 56.0.0. The same generated
`format!("c{i}").lit()` path is present in current main in
`datafusion/sql/src/expr/mod.rs` (`create_named_struct_expr`).
This blocks the mixed-alias Spark compatibility case in
apache/datafusion-spark#364 and apache/datafusion-spark#410.
--
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]