[ 
https://issues.apache.org/jira/browse/HIVE-23206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17091718#comment-17091718
 ] 

Krisztian Kasa commented on HIVE-23206:
---------------------------------------

HiveJoinProjectTransposeRule.RIGHT_PROJECT_BTW_JOIN pulls up the left Project 
however this rule should pull up the right one. 
HiveJoinProjectTransposeRule.LEFT_PROJECT_BTW_JOIN should deal with the left 
one.
 The reason of this HiveJoinProjectTransposeRule extends 
JoinProjectTransposeRule from Calcite which generally pulls the Project from 
the side where it exists. To determine whether there is a project or not it 
uses the *hasLeftChild(call)* and *hasRightChild(call)* methods. In case of the 
mentioned query above the Join has Projects on both sides.

Patch [^HIVE-23206.2.patch]  restrict these rules to pull Project from the 
proper side only.

> Project not defined correctly after reordering a join
> -----------------------------------------------------
>
>                 Key: HIVE-23206
>                 URL: https://issues.apache.org/jira/browse/HIVE-23206
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>            Reporter: Steve Carlin
>            Assignee: Krisztian Kasa
>            Priority: Major
>         Attachments: HIVE-23206.1.patch, HIVE-23206.2.patch
>
>
> The following highlighted line seems to be incorrect in the test suite:
> [https://github.com/apache/hive/blob/master/ql/src/test/results/clientpositive/perf/tez/cbo_query95.q.out#L89]
> Note that the project takes all the columns from the table scan, yet it only 
> needs a couple of them.
> I did some very small debugging on this.  When I removed the 
> applyJoinOrderingTransform here: 
> [https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java#L1897]
> ... the problem goes away.  So presumably one of the rules in there is 
> causing the problem.
> Here is a slightly simplified version of the query which has the same problem 
> (using the same tpc-ds database):
> explain cbo with ws_wh as
> (select ws1.ws_order_number
> from web_sales ws1,web_returns wr2 
> where ws1.ws_order_number = wr2.wr_order_number)
> select 
>    ws_order_number
> from
>    web_sales ws1 
> where
> ws1.ws_order_number in (select wr_order_number
>                             from web_returns,ws_wh
>                             where wr_order_number = ws_wh.ws_order_number)
>  



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

Reply via email to