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

Field-pruning for set operators (except UNION ALL) changes query semantics

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core

      Description

      RelFieldTrimmer#trimFields provides functionality to trim fields for  UNION, UNION ALL, INTERSECT, INTERSECT ALL, EXCEPT, EXCEPT ALL;

      But UNION ALL, INTERSECT, INTERSECT ALL, EXCEPT, EXCEPT ALL works by checking duplication. Column pruning on inputs of SetOp might lead to different semantics.

       

      Take below example for illustration

      emp0:
      name, deptno
       "A",   0
       "B",   1
      
      emp1:
      name, deptno
       "C",   0
       "D",   2
      
      select deptno from
      (select name, deptno from emp0
      intersect
      select name, deptno from emp1)
      
      

      Run above Sql on emp0 and emp1, result is not empty if trim fields on inputs of INTERSECT, but result is empty if DO NOT trim fields on inputs of INTERSECT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jinxing6042@126.com Jin Xing
                Reporter:
                jinxing6042@126.com Jin Xing
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m