sqlfluff / sqlfluff

A modular SQL linter and auto-formatter with support for multiple dialects and templated code.

Home Page:https://www.sqlfluff.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Case statement with the >= or <= is unparsable

mariq41 opened this issue · comments

Search before asking

  • I searched the issues and found no similar issues.

What Happened

I got the following error:
L: 5 | P: 16 | PRS | Line 5, Position 16: Found unparsable section: '<=
| CURRENT_DATE()'

Expected Behaviour

The code is parsed

Observed Behaviour

After executing the SQL statement:
Select
CASE
WHEN DATE_FROM IS NULL THEN '1900-01-01'
ELSE TO_DATE(TO_CHAR(DATE_FROM), 'YYYYMMDD')
END >= CURRENT_DATE()
from t;

I get the following error:
L: 5 | P: 16 | PRS | Line 5, Position 16: Found unparsable section: '<=
| CURRENT_DATE()'

How to reproduce

Select
CASE
WHEN DATE_FROM IS NULL THEN '1900-01-01'
ELSE TO_DATE(TO_CHAR(DATE_FROM), 'YYYYMMDD')
END >= CURRENT_DATE()
from t;

Dialect

Snowflake

Version

3.0.0a6

Configuration

[sqlfluff]
dialect = snowflake
templater = raw

--ignore=templating

#rules = Rule_C001

#exclude_rules = convention.coalesce,aliasing.column,references.consistent,capitalisation.identifiers,layout.commas,aliasing.table, references.keywords,aliasing.expression,layout.commas, capitalisation.literals,structure.join_condition_order, references.special_chars,structure.else_null,structure.subquery, structure.join_condition_order, references.qualification, aliasing.self_alias.column, capitalisation.functions,layout.select_targets, aliasing.forbid, structure.using, ambiguous.join, convention.left_join, structure.column_order,convention.terminator, layout.long_lines,capitalisation.keywords, ambiguous.column_count, structure.column_order,layout.end_of_file,layout.indent,layout.spacing,layout.start_of_file,
exclude_rules = aliasing.self_alias.column, aliasing.table ,aliasing.column ,aliasing.expression ,aliasing.unique.table ,aliasing.unused ,aliasing.length ,aliasing.forbid ,aliasing.unique.column ,ambiguous.distinct ,ambiguous.union ,ambiguous.order_by ,ambiguous.column_count ,ambiguous.join ,ambiguous.column_references ,ambiguous.set_columns ,capitalisation.keywords ,capitalisation.identifiers ,capitalisation.functions ,capitalisation.literals ,capitalisation.types ,convention.not_equal ,convention.coalesce ,convention.select_trailing_comma ,convention.count_rows ,convention.is_null ,convention.terminator ,convention.statement_brackets ,convention.left_join ,convention.blocked_words ,convention.quoted_literals ,convention.casting_style ,jinja.padding ,layout.spacing ,layout.indent ,layout.operators ,layout.commas ,layout.long_lines ,layout.functions ,layout.cte_bracket ,layout.cte_newline ,layout.select_targets ,layout.select_modifiers ,layout.set_operators ,layout.end_of_file ,layout.start_of_file ,references.from ,references.qualification ,references.consistent ,references.keywords ,references.special_chars ,references.quoting ,structure.else_null ,structure.simple_case ,structure.unused_cte ,structure.nested_case ,structure.subquery ,structure.column_order ,structure.using ,structure.distinct ,structure.join_condition_order ,tsql.sp_prefix

large_file_skip_byte_limit=0

warnings = CV09

[sqlfluff:rules:convention.blocked_words]
blocked_words = user

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

Already resolved at #5728 .

@WittierDinosaur can you please close this?
Thanks

Yep, FYI if you put fixes #5704 in your PR description, it'll auto-close