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

JoinProjectTransposeRule should skip Projects containing windowing expression

    XMLWordPrintableJSON

    Details

      Description

      This rule could push windowing expressions within join condition which doesn't make sense.

      For example

      select * from dept a 
           join (select rank() over (order by name) as r, 1 + 1 from dept) as b 
                   on a.name = b.r
      

      Above query produces following plan after the rule

      LogicalProject(DEPTNO=[$0], NAME=[$1], R=[$3], EXPR$1=[$4])
        LogicalProject(DEPTNO=[$0], NAME=[$1], NAME0=[CAST($1):BIGINT NOT NULL], R=[RANK() OVER (ORDER BY $3 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)], EXPR$1=[+(1, 1)])
          LogicalJoin(condition=[=(CAST($1):BIGINT NOT NULL, RANK() OVER (ORDER BY $3 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW))], joinType=[inner])
            LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
            LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vgarg Vineet Garg
                Reporter:
                vgarg Vineet Garg
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

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