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.
Something like
SELECT T FROM Ttoday 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.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 forThas already been replaced with the result ofgenerateSelectWhere(), which is unnamed. Its columns, however, retain their qualification, which is why a qualified form such asARRAY_AGG(T.*)still works.