Skip to content

Commit c8242d9

Browse files
committed
Allow empty options for BigQuery
1 parent 36db176 commit c8242d9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/parser/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7341,6 +7341,10 @@ impl<'a> Parser<'a> {
73417341
pub fn parse_options(&mut self, keyword: Keyword) -> Result<Vec<SqlOption>, ParserError> {
73427342
if self.parse_keyword(keyword) {
73437343
self.expect_token(&Token::LParen)?;
7344+
if self.peek_token() == Token::RParen {
7345+
self.next_token();
7346+
return Ok(vec![]);
7347+
}
73447348
let options = self.parse_comma_separated(Parser::parse_sql_option)?;
73457349
self.expect_token(&Token::RParen)?;
73467350
Ok(options)

tests/sqlparser_bigquery.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,3 +2244,15 @@ fn test_any_type() {
22442244
fn test_any_type_dont_break_custom_type() {
22452245
bigquery_and_generic().verified_stmt("CREATE TABLE foo (x ANY)");
22462246
}
2247+
2248+
#[test]
2249+
fn parse_create_table_with_empty_table_options() {
2250+
let sql = "CREATE TABLE foo (x INT64) OPTIONS()";
2251+
bigquery().verified_stmt(sql);
2252+
}
2253+
2254+
#[test]
2255+
fn parse_create_table_with_empty_table_options_and_column_options() {
2256+
let sql = "CREATE TABLE db.schema.test (x INT64 OPTIONS(description = 'An optional INTEGER field')) OPTIONS()";
2257+
bigquery().verified_stmt(sql);
2258+
}

0 commit comments

Comments
 (0)