Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .sqlfluff-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
369e7f2d21f50c019211a9c8bca4fbd0cf1a0b2b
eacd20ac144148ccce5db1b733bb220a2f80c812
27 changes: 23 additions & 4 deletions crates/lib-dialects/src/sparksql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2786,11 +2786,30 @@ pub fn raw_dialect() -> Dialect {
Ref::keyword("VIEW").to_matchable(),
Ref::keyword("OUTER").optional().to_matchable(),
Ref::new("FunctionSegment").to_matchable(),
// This allows for a table name to precede the alias expression.
Ref::new("SingleIdentifierGrammar")
.optional()
one_of(vec![
Sequence::new(vec![
Ref::new("SingleIdentifierGrammar").to_matchable(),
Sequence::new(vec![
Ref::keyword("AS").optional().to_matchable(),
Delimited::new(vec![
Ref::new("SingleIdentifierGrammar").to_matchable(),
])
.to_matchable(),
])
.config(|this| this.optional())
.to_matchable(),
])
.to_matchable(),
Sequence::new(vec![
Ref::keyword("AS").optional().to_matchable(),
Delimited::new(vec![
Ref::new("SingleIdentifierGrammar").to_matchable(),
])
.to_matchable(),
])
.to_matchable(),
Ref::new("AliasExpressionSegment").optional().to_matchable(),
])
.to_matchable(),
MetaSegment::dedent().to_matchable(),
])
.to_matchable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ file:
- end_bracket: )
- end_bracket: )
- naked_identifier: tbl_name
- alias_expression:
- keyword: AS
- naked_identifier: c_age
- keyword: AS
- naked_identifier: c_age
- lateral_view_clause:
- keyword: LATERAL
- keyword: VIEW
Expand All @@ -87,9 +86,8 @@ file:
- numeric_literal: '80'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: d_age
- keyword: AS
- naked_identifier: d_age
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -141,9 +139,8 @@ file:
- numeric_literal: '60'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c_age
- keyword: AS
- naked_identifier: c_age
- lateral_view_clause:
- keyword: LATERAL
- keyword: VIEW
Expand All @@ -167,9 +164,8 @@ file:
- numeric_literal: '80'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: d_age
- keyword: AS
- naked_identifier: d_age
- groupby_clause:
- keyword: GROUP
- keyword: BY
Expand Down Expand Up @@ -233,9 +229,8 @@ file:
- end_bracket: )
- end_bracket: )
- naked_identifier: tbl_name
- alias_expression:
- keyword: AS
- naked_identifier: c_age
- keyword: AS
- naked_identifier: c_age
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -295,9 +290,8 @@ file:
- end_bracket: )
- end_bracket: )
- naked_identifier: tbl_name
- alias_expression:
- keyword: AS
- naked_identifier: c_age
- keyword: AS
- naked_identifier: c_age
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -357,8 +351,7 @@ file:
- end_bracket: )
- end_bracket: )
- naked_identifier: tbl_name
- alias_expression:
- naked_identifier: c_age
- naked_identifier: c_age
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -467,21 +460,12 @@ file:
- naked_identifier: array_of_structs
- end_bracket: )
- naked_identifier: exploded_people
- alias_expression:
- keyword: AS
- naked_identifier: name
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: age
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: state
- keyword: AS
- naked_identifier: name
- comma: ','
- naked_identifier: age
- comma: ','
- naked_identifier: state
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -534,21 +518,12 @@ file:
- naked_identifier: array_of_structs
- end_bracket: )
- naked_identifier: exploded_people
- alias_expression:
- keyword: AS
- naked_identifier: name
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: age
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: state
- keyword: AS
- naked_identifier: name
- comma: ','
- naked_identifier: age
- comma: ','
- naked_identifier: state
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -653,20 +628,11 @@ file:
- naked_identifier: array_of_structs
- end_bracket: )
- naked_identifier: exploded_people
- alias_expression:
- naked_identifier: name
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: age
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: state
- naked_identifier: name
- comma: ','
- naked_identifier: age
- comma: ','
- naked_identifier: state
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -718,21 +684,12 @@ file:
- column_reference:
- naked_identifier: array_of_structs
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: name
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: age
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: state
- keyword: AS
- naked_identifier: name
- comma: ','
- naked_identifier: age
- comma: ','
- naked_identifier: state
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -837,7 +794,6 @@ file:
- dot: .
- naked_identifier: column2
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: things
- keyword: AS
- naked_identifier: things
- statement_terminator: ;
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ file:
- numeric_literal: '4'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c2
- keyword: AS
- naked_identifier: c2
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -145,9 +144,8 @@ file:
- numeric_literal: '4'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c2
- keyword: AS
- naked_identifier: c2
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -312,15 +310,10 @@ file:
- end_bracket: )
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: c2
- keyword: AS
- naked_identifier: c1
- comma: ','
- naked_identifier: c2
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -389,15 +382,10 @@ file:
- end_bracket: )
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: c2
- keyword: AS
- naked_identifier: c1
- comma: ','
- naked_identifier: c2
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -496,9 +484,8 @@ file:
- numeric_literal: '20'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- keyword: AS
- naked_identifier: c1
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -545,9 +532,8 @@ file:
- numeric_literal: '20'
- end_bracket: )
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- keyword: AS
- naked_identifier: c1
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -616,15 +602,10 @@ file:
- expression:
- numeric_literal: '3'
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: c2
- keyword: AS
- naked_identifier: c1
- comma: ','
- naked_identifier: c2
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -687,15 +668,10 @@ file:
- expression:
- quoted_literal: '''b'''
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- comma: ','
- from_expression:
- from_expression_element:
- table_expression:
- table_reference:
- naked_identifier: c2
- keyword: AS
- naked_identifier: c1
- comma: ','
- naked_identifier: c2
- statement_terminator: ;
- statement:
- select_statement:
Expand Down Expand Up @@ -752,7 +728,6 @@ file:
- expression:
- quoted_literal: '''HOST'''
- end_bracket: )
- alias_expression:
- keyword: AS
- naked_identifier: c1
- keyword: AS
- naked_identifier: c1
- statement_terminator: ;
Loading