sqlfluff icon indicating copy to clipboard operation
sqlfluff copied to clipboard

SQLFluff fails to recognize dollar-quoted string constants (Snowflake)

Open djbelknapaw opened this issue 2 years ago • 0 comments

Search before asking

  • [X] I searched the issues and found no similar issues.

What Happened

I have regex patterns that contain escaped characters. For improved legibility of these patterns, I use dollar-quoted string constants.

Expected Behaviour

I expected SQLFluff to parse these as string constants

Observed Behaviour

SQLFluff could not parse these string constants:

Found unparsable section: ",
                       | $$[;\\n]$$, ', '"

This is a valid regex pattern in snowflake: $$[;\n]$$ (I'm not sure where the extra slash is coming from in the output - it doesn't appear in the dbt-compiled version of the file)

How to reproduce

Create a file with the following contents:

select
    $$\tMy string with a tab$$ as tab_string,
    regexp(my_field, $$[;\n]$$) as my_field_regex
from my_table

Run sqlfluff lint on the file. It gives me the following output:

L:   1 | P:   1 |  PRS | Line 2, Position 5: Found unparsable section: '$$\\tMy
                       | string with a tab$$ as tab_string...'
L:   1 | P:   1 |  PRS | Line 3, Position 20: Found unparsable section: ',
                       | $$[;\\n]$$'
L:   1 | P:   1 | L013 | Column expression without alias. Use explicit `AS`
                       | clause.
L:   1 | P:   1 | L019 | Found leading comma. Expected only trailing.

Dialect

Snowflake

Version

0.10.1

Configuration

.sqlfluff: ` [sqlfluff] templater = dbt dialect = snowflake

[sqlfluff:templater:dbt] profiles_dir = ado

[sqlfluff:templater:dbt:context] target.database=dev

[sqlfluff:rules] max_line_length = 120 `

.sqlfluffignore should be irrelevant

Are you willing to work on and submit a PR to address the issue?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

djbelknapaw avatar Jun 30 '22 15:06 djbelknapaw