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: Support for LATERAL VIEW
clause
#2687
Spark3: Support for LATERAL VIEW
clause
#2687
Conversation
…e' into r7l208/spark3-lateral-view-clause
Codecov Report
@@ Coverage Diff @@
## main #2687 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 163 163
Lines 12025 12034 +9
=========================================
+ Hits 12025 12034 +9
Continue to review full report at Codecov.
|
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.
A lot cleaner now! But spotted a few more things.
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
AnyNumberOf( | ||
Ref("AliasExpressionSegment"), | ||
), |
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.
One last question, I promise!
Wouldn't this allow this?:
LATERAL VIEW OUTER EXPLODE(ARRAY()) AS tbl_name AS c_age;
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.
Please keep asking 🙂 Updated (and will include CI updates as well) to fix this.
Using the below instead.
Ref("SingleIdentifierGrammar", optional=True),
Ref("AliasExpressionSegment", optional=True),
I ran the query with AS tbl_name AS c_age;
and it failed. The first AS
isn't allowed like you raised.
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.
Tested the second AS
and going to push one more commit then should be good to go
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.
Also removed two other test cases that were not valid so thank you for catching that initial case.
Sequence( | ||
"AS", | ||
Ref("SingleIdentifierGrammar"), | ||
optional=True, | ||
), |
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.
My read of the above link is this should be:
Sequence( | |
"AS", | |
Ref("SingleIdentifierGrammar"), | |
optional=True, | |
), | |
Sequence( | |
"AS", | |
Delimited( | |
Ref("SingleIdentifierGrammar") | |
), | |
optional=True, | |
), |
Is that so? And if so should we add a test case for multiple aliases?
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.
Sorry, not firing on all cylinders today.
Sequence(
"AS",
Delimited(
Ref("SingleIdentifierGrammar")
),
),
Should be correct. I forgot to remove the optional clause. I'll add a case for multiple column aliases
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.
Got there in the end!
😁
Brief summary of the change made
updatesqlfluff/core/parser/grammar/anyof.py
to allowexclude
named argument to be an iterableLateralViewClauseSegment
insqlfluff/dialects/dialect_spark3.py
to match/parse the clauseLATERAL
keyword inAliasExpressionSegment
FromExpressionElementSegment
fromsqlfluff/dialects/dialect_ansi.py
to includeLateralViewClauseSegment
Are there any other side effects of this change that we should be aware of?
I added a try/except insqlfluff/core/parser/grammar/anyof.py
that will useany()
to exclude segments then revert to the previously existing code block on a TypeErrorPull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.