Skip to content

sql: allow unaliased subqueries within UDFs #96375

@rharding6373

Description

@rharding6373

There is a compatibility difference with postgres for queries with ambiguous columns.

Examples that fail in postgres with "subquery in FROM must have an alias" but not crdb:

CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
SELECT * FROM (SELECT a FROM t1) JOIN (SELECT a FROM t2) ON true;
SELECT * FROM (SELECT * FROM (SELECT a FROM t1));
SELECT a FROM (SELECT * FROM (SELECT a FROM t1));

The following example fails correctly in crdb with "column reference "a" is ambiguous":

SELECT a FROM (SELECT * FROM (SELECT a FROM t1) JOIN (SELECT a FROM  t2) ON true);

Jira issue: CRDB-24094

Metadata

Metadata

Assignees

Labels

A-sql-routineUDFs and Stored ProceduresC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions