Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6770

Preserve column names when casts are inserted in projects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.38.0
    • 1.39.0
    • core

    Description

      Consider this 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;
      

      The generated plan looks like this:

          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
      

      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.
       

      Attachments

        Issue Links

          Activity

            People

              mbudiu Mihai Budiu
              mbudiu Mihai Budiu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: