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
Spark3 join types #1942
Merged
Merged
Spark3 join types #1942
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bc61ad1
Add Spark3 join types
jpy-git 2104ad7
black format and linting
jpy-git 4ba8152
Merge branch 'main' into spark3_join_types
jpy-git 6f8fde8
Merge branch 'main' into spark3_join_types
jpy-git 668c34a
replace get_eventual_alias with method from ansi
jpy-git 16022f5
Merge branch 'main' into spark3_join_types
jpy-git File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT * FROM employee SEMI JOIN department ON employee.deptno = department.deptno; | ||
SELECT * FROM employee ANTI JOIN department ON employee.deptno = department.deptno; | ||
SELECT * FROM employee LEFT SEMI JOIN department ON employee.deptno = department.deptno; | ||
SELECT * FROM employee LEFT ANTI JOIN department ON employee.deptno = department.deptno; |
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 |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# YML test files are auto-generated from SQL files and should not be edited by | ||
# hand. To help enforce this, the "hash" field in the file must match a hash | ||
# computed by SQLFluff when running the tests. Please run | ||
# `python test/generate_parse_fixture_yml.py` to generate them after adding or | ||
# altering SQL files. | ||
_hash: 083b7cabc2d0da7873019cf780c8a8e0046fd187223d5da951159dbaf4d03ca4 | ||
file: | ||
- base: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: employee | ||
alias_expression: | ||
identifier: SEMI | ||
join_clause: | ||
keyword: JOIN | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: department | ||
join_on_condition: | ||
keyword: 'ON' | ||
expression: | ||
- column_reference: | ||
- identifier: employee | ||
- dot: . | ||
- identifier: deptno | ||
- comparison_operator: '=' | ||
- column_reference: | ||
- identifier: department | ||
- dot: . | ||
- identifier: deptno | ||
- statement_terminator: ; | ||
- base: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: employee | ||
alias_expression: | ||
identifier: ANTI | ||
join_clause: | ||
keyword: JOIN | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: department | ||
join_on_condition: | ||
keyword: 'ON' | ||
expression: | ||
- column_reference: | ||
- identifier: employee | ||
- dot: . | ||
- identifier: deptno | ||
- comparison_operator: '=' | ||
- column_reference: | ||
- identifier: department | ||
- dot: . | ||
- identifier: deptno | ||
- statement_terminator: ; | ||
- base: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: employee | ||
join_clause: | ||
- keyword: LEFT | ||
- keyword: SEMI | ||
- keyword: JOIN | ||
- from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: department | ||
- join_on_condition: | ||
keyword: 'ON' | ||
expression: | ||
- column_reference: | ||
- identifier: employee | ||
- dot: . | ||
- identifier: deptno | ||
- comparison_operator: '=' | ||
- column_reference: | ||
- identifier: department | ||
- dot: . | ||
- identifier: deptno | ||
- statement_terminator: ; | ||
- base: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
wildcard_expression: | ||
wildcard_identifier: | ||
star: '*' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: employee | ||
join_clause: | ||
- keyword: LEFT | ||
- keyword: ANTI | ||
- keyword: JOIN | ||
- from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: department | ||
- join_on_condition: | ||
keyword: 'ON' | ||
expression: | ||
- column_reference: | ||
- identifier: employee | ||
- dot: . | ||
- identifier: deptno | ||
- comparison_operator: '=' | ||
- column_reference: | ||
- identifier: department | ||
- dot: . | ||
- identifier: deptno | ||
- statement_terminator: ; |
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't you just do this:
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.
@tunetheweb looking in ansi JoinKeywords is just the word JOIN,the JOIN types (LEFT, RIGHT, INNER etc) are the same as I've done here?
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.
Think adding those to JOIN keywords would allow things like CROSS SEMI JOIN which isn't possible
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.
Yes but you don’t need to override the
JoinClauseSegment
at all - just theJoinKeywords
So your 80 line change becomes just the above 3 lines.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.
That is true. Your change is more technically accurate since it won’t allow that.
On the other hand, none of our dialects are 100% accurate to the SQL syntax and how likely is it above is used?
To me the point of implementing the parse is so we can implement rules that depend on understanding a SQL component rather than necessarily being 100% accurate to to the syntax. We should look to enforce coding standards and pick up silent syntax errors where ever possible. That SQL would not run so will be picked up. Yes it would be nice if linter picked up these things but I don’t think it’s essential.
The question is, whether the simple 3 line fix over the 80 line one, is simpler, sufficient and the downsides are acceptable? Or do we go the whole copying route and duplicate the code?
I could go either way to be honest. Obviously we override lots of things so another one isn’t an issue. Just saying I probably would have gone the simpler route myself if I’d done this. But maybe I’m just lazy 😀
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 guess for me given it's more accurate to the true syntax and also consistent with the placement of the other join types the 80 lines is fine with me.
Remember you may want to add other non-ansi segments (e.g. natural joins) to this segment in the future so I think it pays to be explicit with the syntax when we can.
I tend not to worry too much about low line count for the sake of it.
"Explicit is better than implicit" 😄