Skip to content

A bare table alias cannot be passed as an aggregate argument #4515

Description

@robert-brunel

Something like SELECT T FROM T today already works and means “project the whole row, as a struct”. For aggregates, however, a bare alias passed as an argument cannot yet be resolved.

SELECT ARRAY_AGG(T) FROM T
-- UNDEFINED_COLUMN: Attempting to query non existing column T

The gap is in the scope in which the aggregate argument gets resolved. SemanticAnalyzer.resolveAsTableRowMaybe() tries to match a bare identifier against the name of a for-each operator in scope, but by that point in the example query, the named table operator for T has already been replaced with the result of generateSelectWhere(), which is unnamed. Its columns, however, retain their qualification, which is why a qualified form such as ARRAY_AGG(T.*) still works.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions