Search before asking
What Happened
The linter fix with bigquery dialect applies a deletion on the alias t and renders the query un-executable due to missing t table.
original query:
with table_arr as (select [1,2,4,2] as arr) SELECT * REPLACE (ARRAY (SELECT DISTINCT el FROM t.arr AS el) AS arr) FROM table_arr t
Expected Behaviour
not applying any change on the alias.
with table_arr as (select [1,2,4,2] as arr) SELECT * REPLACE (ARRAY (SELECT DISTINCT el FROM t.arr AS el) AS arr) FROM table_arr t
Observed Behaviour
the linter deletes the t
with table_arr as (select [1,2,4,2] as arr) SELECT * REPLACE (ARRAY (SELECT DISTINCT el FROM t.arr AS el) AS arr) FROM table_arr
How to reproduce
apply sqlfull fix
Dialect
sqlfluff-fix with bigquery dialect
Version
2.0.2
Configuration
[sqlfluff]
dialect = bigquery
templater = dbt
runaway_limit = 10
indent_unit = space
large_file_skip_byte_limit = 0
max_line_length = 250
exclude_rules=L034,L029
processes = -1
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
load_macros_from_path=macros
[sqlfluff:templater:dbt:context]
sqlfluff_ignore = true
[sqlfluff:indentation]
tab_space_size = 4
indented_joins = False
[sqlfluff:layout:type:comma]
spacing_before = touch
line_position = trailing
[sqlfluff:rules:capitalisation.keywords] # Keywords
capitalisation_policy = upper
[sqlfluff:rules:aliasing.table] # Explicit table alias
aliasing = explicit
[sqlfluff:rules:aliasing.column] # Explicit column alias
aliasing = explicit
[sqlfluff:rules:aliasing.expression] # Column expressions must have alias
allow_scalar = False
[sqlfluff:rules:capitalisation.identifiers] # Unquoted identifiers
extended_capitalisation_policy = lower
[sqlfluff:rules:layout.long_lines]
ignore_comment_lines = True
ignore_comment_clauses = True
[sqlfluff:rules:capitalisation.functions] # Function names
capitalisation_policy = lower
[sqlfluff:rules:capitalisation.literals] # Boolean names
capitalisation_policy = lower
Are you willing to work on and submit a PR to address the issue?
Code of Conduct
Search before asking
What Happened
The linter fix with bigquery dialect applies a deletion on the alias t and renders the query un-executable due to missing t table.
original query:
with table_arr as (select [1,2,4,2] as arr) SELECT * REPLACE (ARRAY (SELECT DISTINCT el FROM t.arr AS el) AS arr) FROM table_arr tExpected Behaviour
not applying any change on the alias.
with table_arr as (select [1,2,4,2] as arr) SELECT * REPLACE (ARRAY (SELECT DISTINCT el FROM t.arr AS el) AS arr) FROM table_arr tObserved Behaviour
the linter deletes the t
with table_arr as (select [1,2,4,2] as arr) SELECT * REPLACE (ARRAY (SELECT DISTINCT el FROM t.arr AS el) AS arr) FROM table_arrHow to reproduce
apply sqlfull fix
Dialect
sqlfluff-fix with bigquery dialect
Version
2.0.2
Configuration
[sqlfluff]
dialect = bigquery
templater = dbt
runaway_limit = 10
indent_unit = space
large_file_skip_byte_limit = 0
max_line_length = 250
exclude_rules=L034,L029
processes = -1
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
load_macros_from_path=macros
[sqlfluff:templater:dbt:context]
sqlfluff_ignore = true
[sqlfluff:indentation]
tab_space_size = 4
indented_joins = False
[sqlfluff:layout:type:comma]
spacing_before = touch
line_position = trailing
[sqlfluff:rules:capitalisation.keywords] # Keywords
capitalisation_policy = upper
[sqlfluff:rules:aliasing.table] # Explicit table alias
aliasing = explicit
[sqlfluff:rules:aliasing.column] # Explicit column alias
aliasing = explicit
[sqlfluff:rules:aliasing.expression] # Column expressions must have alias
allow_scalar = False
[sqlfluff:rules:capitalisation.identifiers] # Unquoted identifiers
extended_capitalisation_policy = lower
[sqlfluff:rules:layout.long_lines]
ignore_comment_lines = True
ignore_comment_clauses = True
[sqlfluff:rules:capitalisation.functions] # Function names
capitalisation_policy = lower
[sqlfluff:rules:capitalisation.literals] # Boolean names
capitalisation_policy = lower
Are you willing to work on and submit a PR to address the issue?
Code of Conduct