Skip to content

Commit

Permalink
fix options
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjanda committed Apr 10, 2024
1 parent ebb64be commit aae333a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4145,6 +4145,8 @@ impl<'a> Parser<'a> {
None
};

let table_options = self.parse_options(Keyword::OPTIONS)?;

// Parse optional `AS ( query )`
let query = if self.parse_keyword(Keyword::AS) {
Some(Box::new(self.parse_query()?))
Expand Down Expand Up @@ -4192,8 +4194,7 @@ impl<'a> Parser<'a> {
};

let strict = self.parse_keyword(Keyword::STRICT);

let table_options = self.parse_options(Keyword::OPTIONS)?;

//Databricks has TBLPROPERTIES after COMMENT
let _table_properties = self.parse_options(Keyword::TBLPROPERTIES)?;
table_properties.extend(_table_properties);
Expand Down
7 changes: 7 additions & 0 deletions tests/sqlparser_bigquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,3 +1385,10 @@ fn test_options_expression() {
"CREATE TABLE `myproject`.`mydataset`.`mytable` (id INT64) OPTIONS (max_staleness = INTERVAL '0-0 0 0:15:0' YEAR TO SECOND)",
);
}

#[test]
fn test_create_table_options_expression() {
bigquery().verified_stmt(
"CREATE OR REPLACE TABLE `myproject`.`mydataset`.`mytable` OPTIONS (description = \"\"\"Project entity stream base\"\"\") AS (SELECT * FROM `myproject`.`mydataset`.`othertable`)",
);
}

0 comments on commit aae333a

Please sign in to comment.