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

Shouldn't trim fields when it's under Union

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 1.25.0
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: