-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ambiguous reference when aliasing in combination with ORDER BY
#8425
Merged
Merged
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
7afeb8b
Minor: Improve the document format of JoinHashMap
Asura7969 6332bec
Merge remote-tracking branch 'origin/main'
Asura7969 cc5e0c7
Merge remote-tracking branch 'origin/main'
Asura7969 a114310
Merge remote-tracking branch 'origin/main'
Asura7969 928c811
Merge remote-tracking branch 'origin/main'
Asura7969 839093e
Merge remote-tracking branch 'origin/main'
Asura7969 a836cde
Merge remote-tracking branch 'origin/main'
Asura7969 5648dc7
Merge branch 'apache:main' into main
Asura7969 a670409
Merge branch 'apache:main' into main
Asura7969 22894a3
Merge branch 'apache:main' into main
Asura7969 73a59d2
Merge branch 'apache:main' into main
Asura7969 46409c2
Merge branch 'apache:main' into main
Asura7969 8a86a4c
Merge branch 'apache:main' into main
Asura7969 cf5c584
Merge branch 'apache:main' into main
Asura7969 62ae9b9
Merge branch 'apache:main' into main
Asura7969 da02fa2
Merge branch 'apache:main' into main
Asura7969 d98eb2e
Merge branch 'apache:main' into main
Asura7969 79e7216
Merge branch 'apache:main' into main
Asura7969 ba51abd
Merge branch 'apache:main' into main
Asura7969 2468f52
Merge branch 'apache:main' into main
Asura7969 180c303
Merge branch 'apache:main' into main
Asura7969 68980ba
Merge branch 'apache:main' into main
Asura7969 9411940
Merge branch 'apache:main' into main
Asura7969 ba28346
Merge branch 'apache:main' into main
Asura7969 df0942f
Merge branch 'apache:main' into main
Asura7969 edccb66
Merge branch 'apache:main' into main
Asura7969 fb74b99
Merge branch 'apache:main' into main
Asura7969 767b004
Merge branch 'apache:main' into main
Asura7969 2e0eef5
Merge branch 'apache:main' into main
Asura7969 749e0c8
Merge branch 'apache:main' into main
Asura7969 9e65482
ambiguous reference
Asura7969 443595c
ignore aliases
Asura7969 5d43a94
Merge branch 'apache:main' into main
Asura7969 b6d85d7
Merge branch 'main' into ambiguous_reference
Asura7969 e6f144e
Merge remote-tracking branch 'origin/ambiguous_reference' into ambigu…
Asura7969 dd5af6d
fix
Asura7969 d755ce6
fix
Asura7969 a338ac2
add test
Asura7969 47b81e6
add test
Asura7969 2f39667
add test
Asura7969 0f65aca
add test
Asura7969 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3546,13 +3546,24 @@ fn test_select_unsupported_syntax_errors(#[case] sql: &str, #[case] error: &str) | |
fn select_order_by_with_cast() { | ||
let sql = | ||
"SELECT first_name AS first_name FROM (SELECT first_name AS first_name FROM person) ORDER BY CAST(first_name as INT)"; | ||
let expected = "Sort: CAST(first_name AS first_name AS Int32) ASC NULLS LAST\ | ||
\n Projection: first_name AS first_name\ | ||
\n Projection: person.first_name AS first_name\ | ||
let expected = "Sort: CAST(person.first_name AS Int32) ASC NULLS LAST\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this certainly looks better |
||
\n Projection: person.first_name\ | ||
\n Projection: person.first_name\ | ||
\n TableScan: person"; | ||
quick_test(sql, expected); | ||
} | ||
|
||
#[test] | ||
fn test_avoid_add_alias() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure logical consistency |
||
// avoiding adding an alias if the column name is the same. | ||
// plan1 = plan2 | ||
let sql = "select person.id as id from person order by person.id"; | ||
let plan1 = logical_plan(sql).unwrap(); | ||
let sql = "select id from person order by id"; | ||
let plan2 = logical_plan(sql).unwrap(); | ||
assert_eq!(format!("{plan1:?}"), format!("{plan2:?}")); | ||
} | ||
|
||
#[test] | ||
fn test_duplicated_left_join_key_inner_join() { | ||
// person.id * 2 happen twice in left side. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment here about what this is doing? I think it is avoiding adding an alias if the column name is the same.
Do we have to worry about relation names here too (like what if
column.relation
is non null?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I didn't expect the scenario where
column.relation
is inconsistent🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of a query like
Where both table1 and table2 have a column named
a
. I think we should add a test for this case too -- I'll try and do so later todayI would expect the test to fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you expected