Skip to content

aliasing.unused false positive when a table alias is used while unnesting #4623

@chronitis

Description

@chronitis

Search before asking

  • I searched the issues and found no similar issues.

What Happened

[redshift] sqlfluff 2.0.2 reports (and fixes) aliasing.unused where the alias is (correctly) not being used in a select statement, but is used unnesting an array in the from statement.

Example:

-- redshift
SELECT
    my_column,
    my_array_value
FROM my_schema.my_table AS t, t.super_array AS my_array_value
L:   4 | P:  28 | AL05 | Alias 't' is never used in SELECT statement.
                       | [aliasing.unused]

Expected Behaviour

The alias is being validly used in the FROM clause of this SELECT statement, and this rule should not trigger.

Observed Behaviour

The table alias is reported as unused, and sqlfluff fix removes it, making the query invalid.

How to reproduce

Reproducer included in What Happened

Dialect

Redshift

Version

2.0.2 (python 3.10.6)

Configuration

Default configuration (aside from dialect).

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions