Skip to content

Unqualified references in uncorrelated subqueries #6326

@mroy-seedbox

Description

@mroy-seedbox

Search before asking

  • I searched the issues and found no similar issues.

Description

When using simple uncorrelated subqueries in a WHERE clause (in order to filter records), RF02 is triggered.

Use case

When a subquery is uncorrelated (especially if it does not even contain a WHERE clause), its content shouldn't need to be qualified.

For example:

SELECT *
FROM tbl
WHERE val = (SELECT MAX(val) FROM tbl);

I don't see what would be the value in qualifying the subquery:

SELECT *
FROM tbl
WHERE val = (SELECT MAX(tbl.val) FROM tbl);

It's almost more confusing, especially when it is the same table being used twice.

Dialect

Snowflake (but should apply to any dialect).

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

  • Yes I am willing to submit a PR!

I'm not sure where to start. I think this one might be beyond me.

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions