Open goldmedal opened 3 days ago
It's similar to https://github.com/apache/datafusion/issues/13477. We use the scalar function to handle the Map type but we should unparse it back to the right SQL.
The SQL for creating a MAP:
select MAP {'a': 1, 'b': 2}
The plan:
Plan: Projection: map(make_array(Utf8("a"), Utf8("b")), make_array(Int64(1), Int64(2))) EmptyRelation
Unparse the plan:
SELECT map(make_array('a', 'b'), make_array(1, 2))
The SQL for accessing a MAP:
select map_col['a'] from (select MAP {'a': 1, 'b': 2} as map_col)
Projection: get_field(map_col, Utf8("a")) Projection: map(make_array(Utf8("a"), Utf8("b")), make_array(Int64(1), Int64(2))) AS map_col EmptyRelation
Unparse the plan
SELECT get_field(map_col, 'a') FROM (SELECT map(make_array('a', 'b'), make_array(1, 2)) AS map_col)
The SQL should be able to roundtrip for SQL-Plan-SQL.
map
make_array
ast::Expr::Map
get_fields
ast::Expr::MapAccess
No response
Is your feature request related to a problem or challenge?
It's similar to https://github.com/apache/datafusion/issues/13477. We use the scalar function to handle the Map type but we should unparse it back to the right SQL.
Map Literal
The SQL for creating a MAP:
The plan:
Unparse the plan:
Access a MAP
The SQL for accessing a MAP:
The plan:
Unparse the plan
Describe the solution you'd like
The SQL should be able to roundtrip for SQL-Plan-SQL.
map
withmake_array
function should be unparsed toast::Expr::Map
get_fields
for MAP should be unparsed toast::Expr::MapAccess
Describe alternatives you've considered
No response
Additional context
No response