Skip to content

Linting error when using aliases in backticks #5356

@brianstoop

Description

@brianstoop

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When using backticks in table aliases and using the alias in the SELECT statement gives an error.

Expected Behaviour

I expect the linting to succeed

Observed Behaviour

The sqlfluff lint failed with the following error:

L:   1 | P:   8 | RF01 | Reference '`nih`.`userID`' refers to table/view not
                       | found in the FROM clause or found in ancestor statement.
                       | [references.from]
L:   2 | P:  44 | AL05 | Alias '`nih`' is never used in SELECT statement.
                       | [aliasing.unused]

How to reproduce

SELECT `nih`.`userID`
FROM `flight_notification_item_history` AS `nih`

Dialect

mysql

Version

sqlfluff, version 2.3.4

Configuration

[sqlfluff]
templater = jinja
sql_file_exts = .sql
large_file_skip_byte_limit = 0

[sqlfluff:rules]
capitalisation_policy = upper

[sqlfluff:rules:references.quoting]
prefer_quoted_identifiers = True

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

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions