Snowflake parser can't parse variant access after cast
FirefoxMetzger opened this issue · comments
Search before asking
- I searched the issues and found no similar issues.
What Happened
When writing Snowflake SQ, casting a column to type object
, and then accessing a specific field of the object SQLfluff's parser fails with
L: 10 | P: 29 | PRS | Line 4, Position 29: Found unparsable section:
| ':name::text as name,\n payload::varian...'
Expected Behaviour
We would like it to not fail and parse the SQL correctly :)
Observed Behaviour
L: 10 | P: 29 | PRS | Line 4, Position 29: Found unparsable section:
| ':name::text as name,\n payload::varian...'
How to reproduce
parse the following SQL with v2.3.5
:
select distinct
payload::variant::object:name::text as name,
payload::variant::object as details,
payload::variant::object:createdAt::timestamp_ntz as created,
payload::variant::object:updatedAt::timestamp_ntz as updated,
payload::variant::object:id::number as id
from raw_source_table
produces:
L: 1 | P: 1 | LT09 | Select targets should be on a new line unless there is
| only one select target.
| [layout.select_targets]
L: 2 | P: 29 | PRS | Line 2, Position 29: Found unparsable section:
| ':name::text as name,\n payload::varian...'
Dialect
The Snowflake dialect.
Version
python -m sqlfluff, version 2.3.5
Configuration
[sqlfluff]
templater = jinja
dialect = snowflake
exclude_rules = AL01, AL04, AL05, AM02, AM03, AM04, AM06, AM07,
CV01, CV02, CV03, CV06, CV08, CV09, CV10, CV11,
LT03, LT05, L019, LT08,
RF01, RF02, RF03, RF05, RF04,
ST02, ST03, ST07, ST06,
TQ01
ignore = templating
large_file_skip_byte_limit = 0
max_line_length = 120
[sqlfluff:indentation]
tab_space_size = 4
indent_unit = space
indented_joins = False
indented_using_on = True
allow_implicit_indents = True
indented_ctes = False
[sqlfluff:rules:aliasing.table]
aliasing.table = explicit
[sqlfluff:rules:aliasing.column]
aliasing.column = explicit
[sqlfluff:rules:aliasing.expression]
allow_scalar = True
[sqlfluff:rules:ambiguous.join]
fully_qualify_join_types = inner
[sqlfluff:rules:layout.long_lines]
ignore_comment_clauses = True
ignore_comment_lines = True
[sqlfluff:rules:ambiguous.column_references]
group_by_and_order_by_style = explicit
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = lower
[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower
unquoted_identifiers_policy = all
[sqlfluff:rules:capitalisation.functions]
extended_capitalisation_policy = lower
[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = lower
[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = lower
[sqlfluff:rules:jinja.padding]
single_space = true
[sqlfluff:rules:layout.spacing]
no_trailing_whitespace = true
extra_whitespace = false
[sqlfluff:rules:layout.functions]
no_space_after_function_name = true
[sqlfluff:rules:layout.select_targets]
wildcard_policy = single
[sqlfluff:rules:layout.set_operators]
set_operator_on_new_line = ['UNION', 'UNION ALL']
[sqlfluff:rules:structure.nested_case]
[sqlfluff:rules:structure.subquery]
forbid_subquery_in = join
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
- I agree to follow this project's Code of Conduct
Awesome. Thanks for working on a fix for this @alanmcruickshank 🚀