Skip to content

Commit ae901ac

Browse files
committed
Enable numeric-prefix identifiers for Databricks dialect
Databricks, built on Spark SQL, allows identifiers that start with digits. The Spark SQL ANTLR lexer defines IDENTIFIER as (UNICODE_LETTER | DIGIT | '_')+, with no restriction on the first character. Enable the existing supports_numeric_prefix() for DatabricksDialect.
1 parent 6f8e7b8 commit ae901ac

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/dialect/databricks.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ impl Dialect for DatabricksDialect {
3939
matches!(ch, 'a'..='z' | 'A'..='Z' | '0'..='9' | '_')
4040
}
4141

42+
fn supports_numeric_prefix(&self) -> bool {
43+
true
44+
}
45+
4246
fn supports_filter_during_aggregation(&self) -> bool {
4347
true
4448
}

tests/sqlparser_databricks.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,10 @@ fn parse_databricks_json_accessor() {
644644
"SELECT raw:store.bicycle.price::DOUBLE FROM store_data",
645645
);
646646
}
647+
648+
#[test]
649+
fn parse_numeric_prefix_identifier() {
650+
databricks().verified_stmt("SELECT * FROM catalog.schema.1st_table");
651+
652+
databricks().verified_stmt("SELECT * FROM a.b.1c");
653+
}

0 commit comments

Comments
 (0)