[X] I searched the issues and found no similar issues.
What Happened
The following error appears when trying to use "sqlfluff parse test1.sql --rules CP01,AL01,AL02,AL04,AM06 --dialect bigquery --config \config\sqlfluff.sqlfluff_for_bigquery" command for the construction "IF ... END IF"
==== parsing violations ====
L: 26 | P: 1 | PRS | Line 26, Position 1: Found unparsable section: 'IF _log.Debug = 1
| THEN\n\tSELECT _SQL;\nELS...'
L: 30 | P: 5 | PRS | Line 30, Position 5: Found unparsable section: 'IF;\n\n--end
| try\nEND;'
Search before asking
What Happened
The following error appears when trying to use "sqlfluff parse test1.sql --rules CP01,AL01,AL02,AL04,AM06 --dialect bigquery --config \config\sqlfluff.sqlfluff_for_bigquery" command for the construction "IF ... END IF"
==== parsing violations ==== L: 26 | P: 1 | PRS | Line 26, Position 1: Found unparsable section: 'IF _log.Debug = 1 | THEN\n\tSELECT _SQL;\nELS...' L: 30 | P: 5 | PRS | Line 30, Position 5: Found unparsable section: 'IF;\n\n--end | try\nEND;'
test11_parse_result.txt
Expected Behaviour
Provide the parsing result without parsing error.
Observed Behaviour
No way to avoid parsing error using nested construction "IF ... END IF"
How to reproduce
Use the following code for the processing file:
CREATE OR REPLACE PROCEDURE place_name.proc_name ( _log STRUCT< Process_ID STRING ,Debug INT64
BEGIN
-- Declaration
DECLARE _Source_Table STRING;
CREATE OR REPLACE TEMP TABLE _SESSION.__Calendar_Target_Buffer ( some_id int64 );
SET _Metric_ID = 1001;
-- define metric details CALL some_place.some_name1 ( _Some_ID);
IF _log.Debug = 1 THEN SELECT _SQL; ELSE SELECT _SQL; END IF;
--end try END;
Dialect
BigQuery
Version
SQLFluff version = 2.3.5 and 3.0.5 Python version = 3.11.2
Configuration
[sqlfluff] sql_file_exts = .sql dialect = bigquery templater = placeholder large_file_skip_byte_limit = 50000 max_line_length = 250
[sqlfluff:templater:placeholder] param_regex = ${(?P[\w_]+)}
[sqlfluff:indentation] indent_unit = tab tab_space_size = 4 allow_implicit_indents = True
[sqlfluff:rules] single_table_references = qualified allow_scalar = False
[sqlfluff:layout:type:bracketed_index_column_list_grammar] spacing_before = touch
[sqlfluff:layout:type:comma] line_position = leading
[sqlfluff:layout:type:common_table_expression] spacing_within = single
[sqlfluff:layout:type:function_name] spacing_within = touch:inline spacing_after = touch
[sqlfluff:rules:aliasing.length] min_alias_length = 2
[sqlfluff:rules:capitalisation.keywords] # Keywords (L010) capitalisation_policy = lower
[sqlfluff:rules:capitalisation.identifiers] # Unquoted identifiers (L014) extended_capitalisation_policy = lower
[sqlfluff:rules:capitalisation.functions] # Function names (L030) capitalisation_policy = lower
[sqlfluff:rules:capitalisation.literals] # Null & Boolean Literals (L040) capitalisation_policy = lower
[sqlfluff:rules:references.consistent] # (L028) single_table_references = qualified
[sqlfluff:rules:capitalisation.types] # datatypes (L063) extended_capitalisation_policy = lower
Are you willing to work on and submit a PR to address the issue?
Code of Conduct