feat: Allow repeated aliases (auto-realias) #187
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows DataFusion to plan queries with repeated aliases and auto-realias them. Here are a few examples:
This query is valid in PostgreSQL but would fail in DataFusion because the schema would contain three
NULLfields. This is now fixed by realiasing the last two expressions asNULL__1andNULL__2.This query is valid in PostgreSQL. While you cannot query
tif this was a subquery in outer query, you can have the outermost query repeat the alias. This would fail in DataFusion because the schema would contain twotfields. This is now fixed by realiasing the last expression ast__1.This is valid in both PostgreSQL and DataFusion. While the alias is
cfor both, the schema has fieldst1.candt2.c, so the query runs.This is valid in PostgreSQL but fails in DataFusion. Upon realiasing the inner query as
t, two fields becomet.c, breaking the schema. This is now fixed by realiasing the last expression asc__1.