From 6bcb0b3b4f9921b37d2a3372a5ba633f54133fce Mon Sep 17 00:00:00 2001 From: Andriy Romanov Date: Wed, 4 Mar 2026 15:02:40 -0800 Subject: [PATCH] Fixed parsing OPTIONS(format = 'CSV') when creating external bigquery table --- src/parser/mod.rs | 2 ++ tests/sqlparser_bigquery.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 75b5bfa76..ecb700aaa 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -6297,6 +6297,8 @@ impl<'a> Parser<'a> { let table_properties = self.parse_options(Keyword::TBLPROPERTIES)?; let table_options = if !table_properties.is_empty() { CreateTableOptions::TableProperties(table_properties) + } else if let Some(options) = self.maybe_parse_options(Keyword::OPTIONS)? { + CreateTableOptions::Options(options) } else { CreateTableOptions::None }; diff --git a/tests/sqlparser_bigquery.rs b/tests/sqlparser_bigquery.rs index ce962cb80..a6b0906ff 100644 --- a/tests/sqlparser_bigquery.rs +++ b/tests/sqlparser_bigquery.rs @@ -591,6 +591,16 @@ fn parse_create_table_with_options() { bigquery().verified_stmt(sql); } +#[test] +fn parse_create_external_table_with_options() { + bigquery().verified_stmt( + "CREATE EXTERNAL TABLE dataset_id.table1 (hvr_tx_seq STRING) OPTIONS(format = 'CSV')", + ); + bigquery().verified_stmt( + "CREATE EXTERNAL TABLE dataset_id.table1 (hvr_tx_seq STRING) OPTIONS(format = 'CSV', allow_quoted_newlines = true, encoding = 'UTF8')", + ); +} + #[test] fn parse_nested_data_types() { let sql = "CREATE TABLE table (x STRUCT, b BYTES(42)>, y ARRAY>)";