You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DISCUSSION] Naming convention for non-aliased columns #3990
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Related to #3882#3722
As of now, not aliased column names gets their name generated using function, arguments and other information ending up with not user-friendly aliases like btrim(test.a,Utf8(\"ab\"))
Describe the solution you'd like
Discuss the naming convention for non-aliased columns.
As an example we can consider
Postgres based
select trim("123")
trim |
-----+
123 |
Trino based
select t.*, 'col_again' from ( select 'col', 2 a, count(1) ) t
_col0|a|_col2|_col3 |
-----+-+-----+---------+
col |2| 1|col_again|
Or any other solutions contributors considers as better solutions
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
thanks @alamb so you happy for both, lets wait @andygrove or @Dandandan to share their thoughts. This is a breaking change and will be good to decide once
I tried making datafusion consistent with postgres in this regard a while back, and I ran into a problem. In the PG example above, the result of the query has two columns named "sum". DataFusion does not allow a result set to have two columns with the same name. Perhaps we need to allow this and only throw an error if attempting to reference a column that is ambiguous.
I tried making datafusion consistent with postgres in this regard a while back, and I ran into a problem. In the PG example above, the result of the query has two columns named "sum". DataFusion does not allow a result set to have two columns with the same name. Perhaps we need to allow this and only throw an error if attempting to reference a column that is ambiguous.
Yes, DF checks the column uniqueness in logical plan builder in validate_unique_names. I agree we can try to move the check to later phase when outer query references an ambiguous column
Activity
comphead commentedon Oct 27, 2022
@andygrove @alamb @Dandandan created a separate ticket on naming convention discussion as you already familiar with this as part of #3882
alamb commentedon Oct 28, 2022
Thanks @comphead -- I don't have any strong opinions on this matter.
comphead commentedon Oct 28, 2022
thanks @alamb so you happy for both, lets wait @andygrove or @Dandandan to share their thoughts. This is a breaking change and will be good to decide once
comphead commentedon Jan 3, 2023
PG query
@alamb here is some investigation on how pg names unaliased columns. We can follow this approach
comphead commentedon Jan 3, 2023
Spark has another naming convention
it uses scalar values, or function names from plan
andygrove commentedon Jan 3, 2023
I tried making datafusion consistent with postgres in this regard a while back, and I ran into a problem. In the PG example above, the result of the query has two columns named "sum". DataFusion does not allow a result set to have two columns with the same name. Perhaps we need to allow this and only throw an error if attempting to reference a column that is ambiguous.
andygrove commentedon Jan 3, 2023
I am +1 for having simpler names.
comphead commentedon Jan 3, 2023
Yes, DF checks the column uniqueness in logical plan builder in
validate_unique_names. I agree we can try to move the check to later phase when outer query references an ambiguous column