Skip to content

Commit 3fa7114

Browse files
authored
Fixed parsing OPTIONS(format = 'CSV') when creating external bigquery table (#2268)
1 parent b6003eb commit 3fa7114

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/parser/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6297,6 +6297,8 @@ impl<'a> Parser<'a> {
62976297
let table_properties = self.parse_options(Keyword::TBLPROPERTIES)?;
62986298
let table_options = if !table_properties.is_empty() {
62996299
CreateTableOptions::TableProperties(table_properties)
6300+
} else if let Some(options) = self.maybe_parse_options(Keyword::OPTIONS)? {
6301+
CreateTableOptions::Options(options)
63006302
} else {
63016303
CreateTableOptions::None
63026304
};

tests/sqlparser_bigquery.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,16 @@ fn parse_create_table_with_options() {
591591
bigquery().verified_stmt(sql);
592592
}
593593

594+
#[test]
595+
fn parse_create_external_table_with_options() {
596+
bigquery().verified_stmt(
597+
"CREATE EXTERNAL TABLE dataset_id.table1 (hvr_tx_seq STRING) OPTIONS(format = 'CSV')",
598+
);
599+
bigquery().verified_stmt(
600+
"CREATE EXTERNAL TABLE dataset_id.table1 (hvr_tx_seq STRING) OPTIONS(format = 'CSV', allow_quoted_newlines = true, encoding = 'UTF8')",
601+
);
602+
}
603+
594604
#[test]
595605
fn parse_nested_data_types() {
596606
let sql = "CREATE TABLE table (x STRUCT<a ARRAY<INT64>, b BYTES(42)>, y ARRAY<STRUCT<INT64>>)";

0 commit comments

Comments
 (0)