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

Formatting One of Snowflakes RLIKE Syntaxes Adds Superfluous Whitespace #478

Closed
chwiese opened this issue Sep 5, 2023 · 3 comments · Fixed by #649
Closed

Formatting One of Snowflakes RLIKE Syntaxes Adds Superfluous Whitespace #478

chwiese opened this issue Sep 5, 2023 · 3 comments · Fixed by #649
Labels
bug Something isn't working snowflake-only style for issues that change the sqlfmt style
Milestone

Comments

@chwiese
Copy link

chwiese commented Sep 5, 2023

Describe the bug
Snowflakes RLIKE has two valid syntaxes. When formatting a Snowflake SQL script that uses the first syntax mentioned in the documentation, sqlfmt adds a whitespace between E and (.

To Reproduce
Format the following:
select rlike('foo', 'bar') from dual;

Expected behavior

select rlike('foo', 'bar')
from dual
;

Actual behavior

select rlike ('foo', 'bar')
from dual
;

Additional context
sqlfmt, version 0.19.2

@tconbeer
Copy link
Owner

tconbeer commented Sep 5, 2023

thanks for the report. Snowflake has similar syntax for like, ilike, etc., as functions instead of infix operators.

While this formatting isn't ideal, snowflake parses it and accepts it as valid.

A quick search of the other major dialects suggests this is snowflake-only.

@tconbeer tconbeer added bug Something isn't working style for issues that change the sqlfmt style labels Sep 5, 2023
@tconbeer tconbeer added this to the v 0.20.0 milestone Sep 15, 2023
@tconbeer
Copy link
Owner

I'm not going to tackle this right now -- because of how the lexer and parser work, it's non-trivial to distinguish between rlike('foo, bar') and rlike('foo', 'bar') when these tokens are lexed, which unfortunately determines the presence or absence of whitespace between the function or operator name and the parenthesis.

@tconbeer
Copy link
Owner

walking this back, given similarity to #641 -- going to fix this one today and respect the existing lack of a space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snowflake-only style for issues that change the sqlfmt style
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants