goldmedal opened a new issue, #13477: URL: https://github.com/apache/datafusion/issues/13477
### Is your feature request related to a problem or challenge? https://github.com/apache/datafusion/pull/13418 supports unparsing the Array plan. We should do the same thing for the struct type. DataFusion will plan the struct SQL to the corresponding scalar function: ## Named Struct Try to select a struct value: ```sql select {a:1, b:2} ``` The plan: ``` Plan: Projection: named_struct(Utf8("a"), Int64(1), Utf8("b"), Int64(2)) EmptyRelation ``` Unparse the plan: ```sql SELECT named_struct('a', 1, 'b', 2) ``` ## Access Struct field Given a table, `strcut_table` with a struct column: ```sql select struct_col.time_field from struct_table ``` The plan: ``` Projection: get_field(struct_table.struct_col, Utf8("time_field")) TableScan: struct_table ``` Unparse the plan: ```sql SELECT get_field(struct_table.struct_col, 'time_field') FROM struct_table ``` ### Describe the solution you'd like The SQL should be able to roundtrip for SQL-Plan-SQL. - The `named_struct` should be unparsed to `ast::Expr::Dictionary` and `ast::DictionaryField`. - The `get_fields` for the struct should be unparsed to `ast::Expr::CompoundIdentifier`. ### Describe alternatives you've considered _No response_ ### Additional context We support two ways to access a struct: ``` struct_col.time_field ``` and ``` struct_col['time_field'] ``` They will be planned to `get_fields(struct_col, 'time_field')`. I prefer to unparse `get_fields` to `CompoundIdentifier` because it's more common in SQL syntax. -- 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]
