Mihai Budiu created CALCITE-6770:
------------------------------------
Summary: Preserve column names when casts are inserted in projects
Key: CALCITE-6770
URL: https://issues.apache.org/jira/browse/CALCITE-6770
Project: Calcite
Issue Type: Improvement
Components: core
Affects Versions: 1.38.0
Reporter: Mihai Budiu
Consider this SQL:
{code:sql}
CREATE TABLE B(id VARCHAR);
CREATE VIEW V1 AS SELECT id, 'x' as y FROM B;
CREATE VIEW V2 AS SELECT id, 'xx' as y FROM B;
CREATE VIEW U AS SELECT * FROM V1 UNION ALL SELECT * FROM V2;
{code}
The generated plan looks like this:
{code}
LogicalUnion(all=[true]), id = 187
LogicalProject(id=[$0], EXPR$1=[CAST($1):VARCHAR(2) NOT NULL]), id = 182
LogicalTableScan(table=[[schema, v1]]), id = 115
LogicalProject(id=[$0], EXPR$1=[CAST($1):VARCHAR(2) NOT NULL]), id = 185
LogicalTableScan(table=[[schema, v2]]), id = 118
{code}
Notice that the second column has a new name, EXPR$1. Preserving the original
column name would produce a more readable plan and error messages.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)