-
-
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.
Add Databricks as a distinct dialect (#4438)
Co-authored-by: Alan Cruickshank <alan@designingoverload.com>
- Loading branch information
1 parent
b600627
commit 009725c
Showing
15 changed files
with
102 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ keywords = | |
formatter | ||
bigquery | ||
clickhouse | ||
databricks | ||
db2 | ||
duckdb | ||
exasol | ||
|
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 |
---|---|---|
|
@@ -45,6 +45,7 @@ keywords = | |
athena | ||
bigquery | ||
clickhouse | ||
databricks | ||
db2 | ||
duckdb | ||
exasol | ||
|
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,20 @@ | ||
"""The Databricks Dialect. | ||
Functionally, it is quite similar to SparkSQL, | ||
however it's much less strict on keywords. | ||
It also has some extensions. | ||
""" | ||
|
||
from sqlfluff.core.dialects import load_raw_dialect | ||
|
||
from sqlfluff.dialects.dialect_databricks_keywords import RESERVED_KEYWORDS | ||
|
||
sparksql_dialect = load_raw_dialect("sparksql") | ||
databricks_dialect = sparksql_dialect.copy_as("databricks") | ||
|
||
databricks_dialect.sets("unreserved_keywords").update( | ||
sparksql_dialect.sets("reserved_keywords") | ||
) | ||
databricks_dialect.sets("unreserved_keywords").difference_update(RESERVED_KEYWORDS) | ||
databricks_dialect.sets("reserved_keywords").clear() | ||
databricks_dialect.sets("reserved_keywords").update(RESERVED_KEYWORDS) |
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,20 @@ | ||
"""A list of databricks reserved keywords.""" | ||
|
||
RESERVED_KEYWORDS = [ | ||
"ANTI", | ||
"CROSS", | ||
"EXCEPT", | ||
"FULL", | ||
"INNER", | ||
"INTERSECT", | ||
"JOIN", | ||
"LATERAL", | ||
"LEFT", | ||
"MINUS", | ||
"NATURAL", | ||
"ON", | ||
"RIGHT", | ||
"SEMI", | ||
"UNION", | ||
"USING", | ||
] |
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
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,2 @@ | ||
[sqlfluff] | ||
dialect = databricks |
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,3 @@ | ||
select * | ||
from shopify_cz.order | ||
; |
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,25 @@ | ||
# 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: bf986346fed8101687984158446015a57adda6a314601c4bd98977bd5a5c3a8b | ||
file: | ||
statement: | ||
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: | ||
- naked_identifier: shopify_cz | ||
- dot: . | ||
- naked_identifier: order | ||
statement_terminator: ; |
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