Skip to content

Trino's lambda notation results in incorrect reference tracking #6141

@namelessjon

Description

@namelessjon

Search before asking

  • I searched the issues and found no similar issues.

What Happened

Trino introduced the TRANSFORM SQL function, which accepts a lambda function as a parameter. The lambda notation includes an arrow sign (->) but the results of this are not interpreted correctly, leading to "Reference 'x.example' refers to table/view not found in the FROM clause or found in ancestor statement."

Expected Behaviour

SQLfluff should parse this sql correctly with no errors related to table/view not found:

SELECT
    a_column,
    TRANSFORM(array_col, x -> x.example) AS array_col_example
FROM example_table

Observed Behaviour

L:   2 | P:   5 | RF03 | Unqualified reference 'a_column' found in single table
                       | select. [references.consistent]
L:   3 | P:  15 | RF03 | Unqualified reference 'array_col' found in single table
                       | select. [references.consistent]
L:   3 | P:  26 | RF03 | Unqualified reference 'x' found in single table select.
                       | [references.consistent]
L:   3 | P:  31 | RF01 | Reference 'x.example' refers to table/view not found in
                       | the FROM clause or found in ancestor statement.
                       | [references.from]
L:   3 | P:  31 | RF03 | Qualified reference 'x.example' found in single table
                       | select which is inconsistent with previous references.
                       | [references.consistent]

How to reproduce

use the example sql, and sqlfluff lint <file>.sql

Dialect

trino

Version

  • sqlfluff 3.1.1
  • python 3.12.3, 3.11.7

Configuration

vanilla

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 workingtrino

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions