Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl Parser<'_> {
}
}
if self.eat_kw("OPTIONS") {
self.options_list()?;
column.options = self.options_list()?;
}
Ok(column)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl Parser<'_> {
}
if self.kw("OPTIONS") && self.char_at(1, '(') {
self.at += 1;
self.options_list()?;
options.extend(self.options_list()?);
}
Ok(StructField::with_options_and_comment(
name, data_type, options, None,
Expand Down
30 changes: 30 additions & 0 deletions crates/sqlquack-syntax-bigquery/src/parse/tests/test_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,36 @@ fn given_unpivot_labels_and_ddl_options_when_parsing_then_they_are_kept() {
other_sql: "CREATE VIEW d.v (a, b) AS SELECT 1, 2",
expected_same: false,
},
TreePairTestCase {
description: "a table column's OPTIONS values are kept",
sql: "CREATE TABLE d.t (a INT64 OPTIONS(description='ab'))",
other_sql: "CREATE TABLE d.t (a INT64 OPTIONS(description='cd'))",
expected_same: false,
},
TreePairTestCase {
description: "a table column's OPTIONS are kept",
sql: "CREATE TABLE d.t (a INT64 NOT NULL OPTIONS(description='ab'))",
other_sql: "CREATE TABLE d.t (a INT64 NOT NULL)",
expected_same: false,
},
TreePairTestCase {
description: "an added column's OPTIONS are kept",
sql: "ALTER TABLE d.t ADD COLUMN a INT64 OPTIONS(description='ab')",
other_sql: "ALTER TABLE d.t ADD COLUMN a INT64 OPTIONS(description='cd')",
expected_same: false,
},
TreePairTestCase {
description: "a struct field's OPTIONS are kept",
sql: "CREATE TABLE d.t (a STRUCT<x INT64 OPTIONS(description='ab')>)",
other_sql: "CREATE TABLE d.t (a STRUCT<x INT64 OPTIONS(description='cd')>)",
expected_same: false,
},
TreePairTestCase {
description: "a struct field's NOT NULL stays apart from its OPTIONS",
sql: "CREATE TABLE d.t (a STRUCT<x INT64 NOT NULL OPTIONS(description='ab')>)",
other_sql: "CREATE TABLE d.t (a STRUCT<x INT64 OPTIONS(description='ab')>)",
expected_same: false,
},
TreePairTestCase {
description: "OPTIONS += is not =",
sql: "CREATE VIEW d.v OPTIONS(labels += [('a', 'b')]) AS SELECT 1 x",
Expand Down
Loading