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

Space added when flattening columns on Snowflake #103

Closed
noel opened this issue Jan 31, 2022 · 4 comments
Closed

Space added when flattening columns on Snowflake #103

noel opened this issue Jan 31, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@noel
Copy link

noel commented Jan 31, 2022

Given a column with the following sql

        _airbyte_data:"AccountId"::varchar as accountid,

sqlfmt will add additional spaces around : like so

            _airbyte_data : "AccountId"::varchar as accountid,
@tconbeer
Copy link
Owner

Thanks for the report, @noel!

I wasn't familiar with that syntax in Snowflake, but it's documented here (and it's not unique to the dialect as a prefix to field names): https://docs.snowflake.com/en/user-guide/json-basics-tutorial-flatten.html

It seems colons should only be surrounded by spaces when they are slice operators. We'll have to infer the context and then format appropriately

@tconbeer tconbeer added bug Something isn't working snowflake labels Jan 31, 2022
@tconbeer
Copy link
Owner

I should have mentioned, as a workaround, you can use -- fmt: off and -- fmt: on comments to surround the lines in your file that are causing the issue, so you can continue to use sqlfmt

tconbeer added a commit that referenced this issue Feb 1, 2022
tconbeer added a commit that referenced this issue Feb 1, 2022
* fix: no space around colons #103

* chore: update changelog

* fix: changelog typo
@tconbeer
Copy link
Owner

tconbeer commented Feb 1, 2022

Fixed by #106 -- this will be included in the 0.5.0 release this week.

@tconbeer tconbeer closed this as completed Feb 1, 2022
@tconbeer
Copy link
Owner

tconbeer commented Feb 2, 2022

0.5.0 has been released! Please upgrade for the patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants