-
-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spark3: Support for
LATERAL VIEW
clause (#2687)
* allow named argument to accept an iterable * updated to allow for LATERAL VIEW * black * use OneOf instead of list for exclude * use get_segment to define get_eventual_alias * remove unused imports * PR feedback * black * Update src/sqlfluff/dialects/dialect_spark3.py Co-authored-by: Barry Pollard <barry_pollard@hotmail.com> * remove AnyNumberOf AliasExpressionSegments * black * remove two invalid test cases and update LateralViewClauseSegment * refresh yml * updates to LateralViewClauseSegment * excldue spark3 from L026 by default * black Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
- Loading branch information
1 parent
0307c76
commit ef27896
Showing
5 changed files
with
469 additions
and
14 deletions.
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
48 changes: 48 additions & 0 deletions
48
test/fixtures/dialects/spark3/select_from_lateral_view.sql
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,48 @@ | ||
SELECT | ||
id, | ||
name, | ||
age, | ||
class, | ||
address, | ||
c_age, | ||
d_age | ||
FROM person | ||
LATERAL VIEW EXPLODE(ARRAY(30, 60)) tbl_name AS c_age | ||
LATERAL VIEW EXPLODE(ARRAY(40, 80)) AS d_age; | ||
|
||
SELECT | ||
c_age, | ||
COUNT(*) AS record_count | ||
FROM person | ||
LATERAL VIEW EXPLODE(ARRAY(30, 60)) AS c_age | ||
LATERAL VIEW EXPLODE(ARRAY(40, 80)) AS d_age | ||
GROUP BY c_age; | ||
|
||
SELECT | ||
id, | ||
name, | ||
age, | ||
class, | ||
address, | ||
c_age, | ||
d_age | ||
FROM person | ||
LATERAL VIEW EXPLODE(ARRAY()) tbl_name AS c_age; | ||
|
||
SELECT | ||
id, | ||
name, | ||
age, | ||
class, | ||
address, | ||
c_age | ||
FROM person | ||
LATERAL VIEW OUTER EXPLODE(ARRAY()) tbl_name AS c_age; | ||
|
||
SELECT | ||
person.id, | ||
exploded_people.name, | ||
exploded_people.age, | ||
exploded_people.state | ||
FROM person | ||
LATERAL VIEW INLINE(array_of_structs) exploded_people AS name, age, state |
Oops, something went wrong.