Skip to content

CTAS with an explicit schema fails for qualified columns with the same name #23878

Description

@lyne7-sc

Describe the bug

CTAS with an explicit schema fails when qualified source columns have the same unqualified name.

To Reproduce

CREATE TABLE dup_src AS VALUES (1, 2);

CREATE TABLE dup_ctas_with_schema(left_c1 BIGINT, right_c1 BIGINT) AS
SELECT dup_src.column1, right_src.column1
FROM dup_src
CROSS JOIN (SELECT column2 AS column1 FROM dup_src) right_src;

The second statement fails with:

Error: Schema error: Ambiguous reference to unqualified field column1

Expected behavior

The CREATE TABLE statement should succeed because the source columns are qualified and the target column names are unique.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions