You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/10/07 00:03:00 UTC

[jira] [Work logged] (HIVE-24199) Incorrect result when subquey in exists contains limit

     [ https://issues.apache.org/jira/browse/HIVE-24199?focusedWorklogId=496240&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-496240 ]

ASF GitHub Bot logged work on HIVE-24199:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Oct/20 00:02
            Start Date: 07/Oct/20 00:02
    Worklog Time Spent: 10m 
      Work Description: vineetgarg02 commented on a change in pull request #1525:
URL: https://github.com/apache/hive/pull/1525#discussion_r500661508



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSubQueryRemoveRule.java
##########
@@ -406,6 +409,16 @@ private RexNode rewriteInExists(RexSubQuery e, Set<CorrelationId> variablesSet,
         offset = offset + 1;
         builder.push(e.rel);
       }
+    } else if (e.getKind() == SqlKind.EXISTS && !variablesSet.isEmpty()) {
+      // Query has 'exists' and correlation:

Review comment:
       Can you add a comment to explain/mention why limit is being removed for correlated EXISTs?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 496240)
    Time Spent: 0.5h  (was: 20m)

> Incorrect result when subquey in exists contains limit
> ------------------------------------------------------
>
>                 Key: HIVE-24199
>                 URL: https://issues.apache.org/jira/browse/HIVE-24199
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code:java}
> create table web_sales (ws_order_number int, ws_warehouse_sk int) stored as orc;
> insert into web_sales values
> (1, 1),
> (1, 2),
> (2, 1),
> (2, 2);
> select * from web_sales ws1
> where exists (select 1 from web_sales ws2 where ws1.ws_order_number = ws2.ws_order_number limit 1);
> 1	1
> 1	2
> {code}
> {code:java}
> CBO PLAN:
> HiveSemiJoin(condition=[=($0, $2)], joinType=[semi])
>   HiveProject(ws_order_number=[$0], ws_warehouse_sk=[$1])
>     HiveFilter(condition=[IS NOT NULL($0)])
>       HiveTableScan(table=[[default, web_sales]], table:alias=[ws1])
>   HiveProject(ws_order_number=[$0])
>     HiveSortLimit(fetch=[1])          <-- This shouldn't be added
>       HiveProject(ws_order_number=[$0])
>         HiveFilter(condition=[IS NOT NULL($0)])
>           HiveTableScan(table=[[default, web_sales]], table:alias=[ws2])
> {code}
> Limit n on the right side of the join reduces the result set coming from the right to only n record hence not all the ws_order_number values are included which leads to correctness issue.



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