-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Is your feature request related to a problem or challenge?
After #15090, we remove the wildacrd expression from the logical plan layer. The unparser will generate the real column name for the select item. The unparsing result (#15090 (comment)) of an unnest plan would like as below:
SELECT "UNNEST(make_array(Int64(1),Int64(2),Int64(3)))" FROM UNNEST([1, 2, 3])
It's only executable for DataFusion. Other databases won't use this kind of column name.
Postgres and DuckDB using unnest as the column name.
psql=# select * from unnest(array[1,2,3]);
unnest
--------
1
2
3
(3 rows)
psql=# select unnest from unnest(array[1,2,3]);
unnest
--------
1
2
3
(3 rows)
BigQuery
select * from unnest(array[1,2,3])
---
f0_
1
2
3
However, we can't select f0_ directly.
select f0_ from unnest(array[1,2,3])
---
Unrecognized name: f0_ at [1:8]
Describe the solution you'd like
I think maybe we can unparse the unnest table factor to SubqueryAlias with a default column alias. For example
SELECT "UNNEST(make_array(Int64(1),Int64(2),Int64(3)))" FROM UNNEST([1, 2, 3]) as unnest_alias("UNNEST(make_array(Int64(1),Int64(2),Int64(3)))")
This way can keep the column name created by DataFusion. The SQL can also be executed by other databases.
I think @blaginin's work #14781 pretty matches this approach (#14781 (comment)). Maybe it can solve this issue.
Describe alternatives you've considered
No response
Additional context
No response