Skip to content

Commit a345ec1

Browse files
committed
format option labels without leading space
1 parent b374f0e commit a345ec1

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/ast/ddl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ impl fmt::Display for ViewColumnDef {
543543
if let Some(options) = self.options.as_ref() {
544544
write!(
545545
f,
546-
" OPTIONS ({})",
546+
" OPTIONS({})",
547547
display_comma_separated(options.as_slice())
548548
)?;
549549
}
@@ -628,7 +628,7 @@ pub enum ColumnOption {
628628
/// BigQuery specific: Explicit column options in a view [1] or table [2]
629629
/// Syntax
630630
/// ```sql
631-
/// OPTIONS (description="field desc")
631+
/// OPTIONS(description="field desc")
632632
/// ```
633633
/// [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#view_column_option_list
634634
/// [2]: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#column_option_list
@@ -707,7 +707,7 @@ impl fmt::Display for ColumnOption {
707707
}
708708
}
709709
SqlOptions(options) => {
710-
write!(f, "OPTIONS ({})", display_comma_separated(options))
710+
write!(f, "OPTIONS({})", display_comma_separated(options))
711711
}
712712
}
713713
}

src/ast/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ pub enum CreateTableOptions {
13761376
/// <https://www.postgresql.org/docs/current/sql-createtable.html>
13771377
With(Vec<SqlOption>),
13781378
/// Options specified using the `OPTIONS` keyword.
1379-
/// e.g. `OPTIONS (description = "123")`
1379+
/// e.g. `OPTIONS(description = "123")`
13801380
///
13811381
/// <https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#table_option_list>
13821382
Options(Vec<SqlOption>),
@@ -1389,7 +1389,7 @@ impl fmt::Display for CreateTableOptions {
13891389
write!(f, "WITH ({})", display_comma_separated(with_options))
13901390
}
13911391
CreateTableOptions::Options(options) => {
1392-
write!(f, "OPTIONS ({})", display_comma_separated(options))
1392+
write!(f, "OPTIONS({})", display_comma_separated(options))
13931393
}
13941394
CreateTableOptions::None => Ok(()),
13951395
}

tests/sqlparser_bigquery.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ fn parse_create_view_with_options() {
103103
let sql = trim_sql(
104104
r#"
105105
CREATE VIEW myproject.mydataset.newview
106-
(name, age OPTIONS (description = "field age"))
107-
OPTIONS
108-
(expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 48 HOUR),
106+
(name, age OPTIONS(description = "field age"))
107+
OPTIONS(expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 48 HOUR),
109108
friendly_name = "newview",
110109
description = "a view that expires in 2 days",
111110
labels = [("org_unit", "development")])
@@ -148,7 +147,7 @@ fn parse_create_view_with_options() {
148147
query.to_string()
149148
);
150149
assert_eq!(
151-
r#"OPTIONS (expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 48 HOUR), friendly_name = "newview", description = "a view that expires in 2 days", labels = [("org_unit", "development")])"#,
150+
r#"OPTIONS(expiration_timestamp = TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 48 HOUR), friendly_name = "newview", description = "a view that expires in 2 days", labels = [("org_unit", "development")])"#,
152151
options.to_string()
153152
);
154153
let CreateTableOptions::Options(options) = options else {
@@ -173,12 +172,11 @@ fn parse_create_table_with_options() {
173172
let sql = trim_sql(
174173
r#"
175174
CREATE TABLE mydataset.newtable
176-
(x INT64 NOT NULL OPTIONS (description = "field x"),
177-
y BOOL OPTIONS (description = "field y"))
175+
(x INT64 NOT NULL OPTIONS(description = "field x"),
176+
y BOOL OPTIONS(description = "field y"))
178177
179178
PARTITION BY _PARTITIONDATE
180-
CLUSTER BY userid, age
181-
OPTIONS(partition_expiration_days = 1,
179+
CLUSTER BY userid, age OPTIONS(partition_expiration_days = 1,
182180
description = "table option description")
183181
"#,
184182
);
@@ -258,8 +256,8 @@ fn parse_create_table_with_options() {
258256
let sql = trim_sql(
259257
r#"
260258
CREATE TABLE mydataset.newtable
261-
(x INT64 NOT NULL OPTIONS (description = "field x"),
262-
y BOOL OPTIONS (description = "field y"))
259+
(x INT64 NOT NULL OPTIONS(description = "field x"),
260+
y BOOL OPTIONS(description = "field y"))
263261
264262
CLUSTER BY userid
265263
OPTIONS(partition_expiration_days = 1,

0 commit comments

Comments
 (0)