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

sqlfmt incorrect reformatted JSON access path, breaking all accesses. #568

Closed
jlucas91 opened this issue Mar 10, 2024 · 1 comment
Closed

Comments

@jlucas91
Copy link

Describe the bug
We store json blobs within columns throughout our data pipeline. We'll then parse the JSON blob's field/values into their own columns in later stages. sqlfmt incorrectly lowercased the access path when retrieving data from the JSON blob. This lead to all accesses silently failing.

To Reproduce
Given the original snippet:

with test as (
    select
        cast(json:source_payload:orderId as varchar) as order_id,
    from source
)
select *
from test

sqlfmt formats to:

with
    test as (
        select cast(json:source_payload:orderid as varchar) as order_id, from source
    )
select *
from test

Note that orderId has become orderid. This is not a safe fix.

Expected behavior
Only safe formatting fixes should be performed.

Actual behavior
The json access path is broken.

Additional context
sqlfmt, version 0.21.2

@tconbeer
Copy link
Owner

This duplicates #269

Please see that issue and the related note about the "help wanted" tag

@tconbeer tconbeer closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants