Skip to content

Commit c277283

Browse files
committed
databricks: TBLPROPERTIES after COMMENT
1 parent 832fcb2 commit c277283

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/parser/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,7 @@ impl<'a> Parser<'a> {
40314031
// PostgreSQL supports `WITH ( options )`, before `AS`
40324032
let with_options = self.parse_options(Keyword::WITH)?;
40334033

4034-
let table_properties = self.parse_options(Keyword::TBLPROPERTIES)?;
4034+
let mut table_properties = self.parse_options(Keyword::TBLPROPERTIES)?;
40354035

40364036
let engine = if self.parse_keyword(Keyword::ENGINE) {
40374037
self.expect_token(&Token::Eq)?;
@@ -4194,6 +4194,9 @@ impl<'a> Parser<'a> {
41944194
let strict = self.parse_keyword(Keyword::STRICT);
41954195

41964196
let table_options = self.parse_options(Keyword::OPTIONS)?;
4197+
//Databricks has TBLPROPERTIES after COMMENT
4198+
let _table_properties = self.parse_options(Keyword::TBLPROPERTIES)?;
4199+
table_properties.extend(_table_properties);
41974200

41984201
Ok(CreateTableBuilder::new(table_name)
41994202
.temporary(temporary)

tests/sqlparser_databricks.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,10 @@ fn test_rlike() {
7878
let sql = r#"SELECT R'%SystemDrive%\Users\John' RLIKE R'%SystemDrive%\\Users.*'"#;
7979
databricks_unescaped().verified_stmt(sql);
8080
}
81+
82+
#[test]
83+
fn test_create_table_comment_tblproperties() {
84+
let sql = "CREATE TABLE main.dbt_cloud_lukasz.customers (customer_id BIGINT COMMENT 'Customer Unique identifier', first_name STRING, last_name STRING) USING delta TBLPROPERTIES ('delta.checkpoint.writeStatsAsJson' = 'false') COMMENT 'The ''customers'' table.'";
85+
86+
databricks_unescaped().verified_stmt(sql);
87+
}

0 commit comments

Comments
 (0)