[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 WHILE ... END WHILE:
==== parsing violations ====
L: 27 | P: 1 | PRS | Line 27, Position 1: Found unparsable section: 'WHILE _indx <
| ARRAY_LENGTH(_Metrics) DO\n...'
L: 37 | P: 5 | PRS | Line 37, Position 5: Found unparsable section: 'WHILE;\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 WHILE ... END WHILE:
==== parsing violations ==== L: 27 | P: 1 | PRS | Line 27, Position 1: Found unparsable section: 'WHILE _indx < | ARRAY_LENGTH(_Metrics) DO\n...' L: 37 | P: 5 | PRS | Line 37, Position 5: Found unparsable section: 'WHILE;\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 WHILE ... END WHILE
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);
-- Loop through the list of metrics to run them WHILE _indx < ARRAY_LENGTH(_Metrics) DO
SET _indx = _indx + 1; END WHILE;
--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