dataform-co/dataform

dataform format: if-based columns are indented at the same level as the "select" clause

Opened this issue · 2 comments

dataform --version returns 3.0.2

Initial sqlx file:

config {
  type: "view",
  schema: "my_schema"
}

SELECT
  id,
  IF( duration >= 120, TRUE, FALSE ) AS flag_a
FROM
  TABLE

After executing dataform format:

config {
  type: "view",
  schema: "my_schema"
}

SELECT
  id,
IF
  ( duration >= 120, TRUE, FALSE ) AS flag_a
FROM
  TABLE

Expected:

config {
  type: "view",
  schema: "my_schema"
}

SELECT
  id,
  IF( duration >= 120, TRUE, FALSE ) AS flag_a
FROM
  TABLE

Reproduced on my machine with dataform v3.0.0

Ekrekr commented

Hi Kevin,

Agreed this is weird. This SQL formatting is actually handled by this package: https://github.com/google/google-sql-syntax-ts. It's the open sourced code from BigQuery's internal formatter, and it doesn't conform to a lot of SQL style principles - so I'm interested in replacing it.