Search before asking
What Happened
Consider the following SQL
SELECT
non_aliased_thing
, b.thing
FROM foo.bar a
LATERAL FLATTEN(input => a.rec) b
;
This is obviously not ideal, due to the lack of alias on non_aliased_thing, but if there isn't a name clash, it will run.
Running sqlfluff fix raises the following.

Expected Behaviour
It should raise an unfixable error about the ambiguous column. It should not strip the alias.
Observed Behaviour
It strips the alias, creating the following.
SELECT
non_aliased_thing
, b.thing
FROM foo.bar
LATERAL FLATTEN(input => a.rec) b
;
This corrupts the sql
How to reproduce
sqlfluff fix the above
Dialect
Snowflake
Version
2.0.7
Configuration
[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 the following SQL
This is obviously not ideal, due to the lack of alias on

non_aliased_thing, but if there isn't a name clash, it will run.Running
sqlfluff fixraises the following.Expected Behaviour
It should raise an unfixable error about the ambiguous column. It should not strip the alias.
Observed Behaviour
It strips the alias, creating the following.
This corrupts the sql
How to reproduce
sqlfluff fixthe aboveDialect
Snowflake
Version
2.0.7
Configuration
Are you willing to work on and submit a PR to address the issue?
Code of Conduct