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:
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.
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:
The plan:
Unparse the plan:
Access Struct field
Given a table,
strcut_table
with a struct column:The plan:
Unparse the plan:
Describe the solution you'd like
The SQL should be able to roundtrip for SQL-Plan-SQL.
named_struct
should be unparsed toast::Expr::Dictionary
andast::DictionaryField
.get_fields
for the struct should be unparsed toast::Expr::CompoundIdentifier
.Describe alternatives you've considered
No response
Additional context
We support two ways to access a struct:
and
They will be planned to
get_fields(struct_col, 'time_field')
. I prefer to unparseget_fields
toCompoundIdentifier
because it's more common in SQL syntax.