Open
Description
When formatting BigQuery DDL statement with OPTIONS on a Struct field, any space between the type definition and the Options definition is removed, resulting in an invalid statement.
Input data
CREATE TABLE `project.dataset.format_test`
(
str STRING OPTIONS(description="A string field."),
int INT64 OPTIONS(description="An int64 field."),
record STRUCT<nested INT64 OPTIONS(description="a struct field")> OPTIONS(description="a struct")
)
Expected Output
CREATE TABLE
`project.dataset.format_test` (
str STRING OPTIONS(description = "A string field."),
int INT64 OPTIONS(description = "An int64 field."),
record STRUCT<nested INT64 OPTIONS(description ="a struct field")> OPTIONS(description = "a struct")
)
Actual Output
CREATE TABLE
`project.dataset.format_test` (
str STRING OPTIONS(description = "A string field."),
int INT64 OPTIONS(description = "An int64 field."),
record STRUCT<nested INT64OPTIONS(description ="a struct field")> OPTIONS(description = "a struct")
)
Usage
To run this I've stored the input in a file called example-sql.sql
and am running:
> sql-formatter --v
12.2.3
> sql-formatter -l bigquery example-sql.sql
CREATE TABLE
`project.dataset.format_test` (
str STRING OPTIONS(description = "A string field."),
int INT64 OPTIONS(description = "An int64 field."),
record STRUCT<nested INT64OPTIONS(description ="a struct field")> OPTIONS(description = "a struct")
)