sqlfluff / sqlfluff

A modular SQL linter and auto-formatter with support for multiple dialects and templated code.
https://www.sqlfluff.com
MIT License
7.26k stars 643 forks source link

Construction "EXECUTE IMMEDIATE ... INTO ..." is not parsed for BigQuery #5838

Closed SvetlanaShulman closed 2 weeks ago

SvetlanaShulman commented 2 weeks ago

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 "EXECUTE IMMEDIATE ... INTO ...": ==== parsing violations ==== L: 26 | P: 1 | PRS | Line 26, Position 1: Found unparsable section: 'EXECUTE IMMEDIATE | _SQL INTO _Value;'

test11_parse_result.txt

Expected Behaviour

Provide the parsing result without parsing error.

Observed Behaviour

No way to avoid parsing error using the construction "EXECUTE IMMEDIATE ... INTO ..."

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);

EXECUTE IMMEDIATE _SQL INTO _Value;

--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

keraion commented 2 weeks ago

This has been fixed with #5820 and should be in the next release.

greg-finley commented 2 weeks ago

dupe