Search before asking
What Happened
Consider:
SELECT
a.foo
, b.bar
FROM foo.baz a
INNER JOIN foo.baz B
ON a.thing = b.thing
;
In this example, aliases should be lowercase.
sqlfluff fix raises this error

Expected Behaviour
I would expect it to correct the capitalisation of the alias, leaving:
SELECT
a.foo
, b.bar
FROM foo.baz a
INNER JOIN foo.baz b
ON a.thing = b.thing
;
Observed Behaviour
It strips the alias, corrupting the SQL
SELECT
a.foo
, b.bar
FROM foo.baz a
INNER JOIN foo.baz
ON a.thing = b.thing
;
How to reproduce
As above, sqlfluff fix the example
Dialect
Snowflake
Version
2.0.7
Configuration
I don't think the config is relevant here, but:
[sqlfluff]
# https://docs.sqlfluff.com/en/stable/configuration.html#default-configuration
verbose = 0
nocolor = False
dialect = snowflake
templater = jinja
rules = None
exclude_rules = AL01,AM04,LT05,RF06,ST01,ST06
recurse = 0
output_line_length = 120
runaway_limit = 10
ignore = None
ignore_templated_areas = True
encoding = autodetect
disable_noqa = False
sql_file_exts = .sql,.sql.j2,.dml
fix_even_unparsable = False
large_file_skip_byte_limit = 200000
max_line_length = 120
[sqlfluff:indentation]
indented_joins = False
indented_ctes = False
indented_using_on = True
indent_unit = space
tab_space_size = 2
template_blocks_indent = True
allow_implicit_indents = True
[sqlfluff:templater]
unwrap_wrapped_queries = True
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
[sqlfluff:templater:jinja:macros]
# Macros provided as builtins for dbt projects
dbt_ref = {% macro ref(model_ref) %}{{model_ref}}{% endmacro %}
dbt_source = {% macro source(source_name, table) %}{{source_name}}_{{table}}{% endmacro %}
dbt_config = {% macro config() %}{% for k in kwargs %}{% endfor %}{% endmacro %}
dbt_var = {% macro var(variable, default='') %}item{% endmacro %}
dbt_is_incremental = {% macro is_incremental() %}True{% endmacro %}
# Some rules can be configured directly from the config common to other rules.
[sqlfluff:rules]
allow_scalar = True
single_table_references = consistent
unquoted_identifiers_policy = all
[sqlfluff:layout:type:comma]
line_position = leading
[sqlfluff:layout:type:binary_operator]
line_position = leading
[sqlfluff:rules:aliasing.column]
aliasing = explicit
[sqlfluff:rules:aliasing.expression]
allow_scalar = False
[sqlfluff:rules:aliasing.table]
aliasing = implicit
[sqlfluff:rules:capitalisation.functions]
extended_capitalisation_policy = upper
[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper
[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = upper
[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = upper
[sqlfluff:rules:convention.count_rows]
prefer_count_1 = False
prefer_count_0 = False
[sqlfluff:rules:convention.select_trailing_comma]
select_clause_trailing_comma = forbid
[sqlfluff:rules:convention.terminator]
multiline_newline = True
require_final_semicolon = True
[sqlfluff:rules:layout.long_lines]
ignore_comment_lines = False
[sqlfluff:rules:references.keywords]
unquoted_identifiers_policy = aliases
ignore_words = timestamp
[sqlfluff:rules:references.quoting]
ignore_words = date
[sqlfluff:rules:structure.subquery]
# By default, allow subqueries in FROM clauses, but not JOIN clauses.
forbid_subquery_in = join
Are you willing to work on and submit a PR to address the issue?
Code of Conduct
Search before asking
What Happened
Consider:
In this example, aliases should be lowercase.

sqlfluff fixraises this errorExpected Behaviour
I would expect it to correct the capitalisation of the alias, leaving:
Observed Behaviour
It strips the alias, corrupting the SQL
How to reproduce
As above,
sqlfluff fixthe exampleDialect
Snowflake
Version
2.0.7
Configuration
I don't think the config is relevant here, but:
Are you willing to work on and submit a PR to address the issue?
Code of Conduct