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

Shouldn't trim fields when it's under Union

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: 1.25.0
    • Component/s: None
    • Labels:
      None

      Description

      Consider case like this:

       

      String sql =
          "select \n"
          + "   gender, \n"
          + "   count(*) \n"
          + "from \n"
          + "(\n"
          + "  (select gender, empno from EMPS) \n"
          + "  union \n"
          + "  (select gender, empno from EMPS)\n"
          + ") group by gender";
      
      

      And the plan is:

       

      EnumerableAggregate(group=[{0}], EXPR$1=[COUNT()])
        EnumerableUnion(all=[false])
          EnumerableProject(GENDER=[$3])
            EnumerableTableScan(table=[[SALES, EMPS]])
          EnumerableProject(GENDER=[$3])
            EnumerableTableScan(table=[[SALES, EMPS]])
      
      

       

      The col empno has been trimmed, this changes the semantics cuz union will distinct values.

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Aron.tao Jiatao Tao
                Reporter:
                Aron.tao Jiatao Tao
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: