Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataform format fails on case/between statements #1539

Open
spatel11 opened this issue Sep 11, 2023 · 1 comment
Open

dataform format fails on case/between statements #1539

spatel11 opened this issue Sep 11, 2023 · 1 comment
Assignees
Labels

Comments

@spatel11
Copy link

The following Definition

config {
  "type": "table"
}

SELECT CASE 
        WHEN 1 BETWEEN 2 AND 3 THEN 'test1'
        ELSE 'test2'
        END

Will result in a formatting error:

definitions/Between.sqlx: Unable to format "config {
  "type": "...".

when dataform format is run.
I'm using the bigquery warehouse type, but other types that I tried (redshift, snowflake) also failed on this definition.

The definition does compile however, and it's a valid query (at least according to bigquery)

An alternative formulation:

config {
  "type": "table"
}

SELECT CASE 
        WHEN 1 >= 2 AND 1 <= 3 THEN 'test1'
        ELSE 'test2'
        END

formats successfully.

@Ekrekr
Copy link
Contributor

Ekrekr commented Apr 3, 2024

I think this is a bug in the SQL formatter that we use - and the error it gives isn't very helpful for that.

I'm in the process of open sourcing the GoogleSQL definition and formatter, to replace the current SQL formatter, which should fix this! If not, I'll take a look then.

@Ekrekr Ekrekr self-assigned this Apr 3, 2024
@Ekrekr Ekrekr added the bug label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants