Vineet Garg created CALCITE-3824:
------------------------------------

             Summary: JoinProjectTransposeRule should skip Projects containing 
windowing expression
                 Key: CALCITE-3824
                 URL: https://issues.apache.org/jira/browse/CALCITE-3824
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Vineet Garg
            Assignee: Vineet Garg


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

For example

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

Above query produces following plan after the rule
{code}
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]])
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to