You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/04/28 05:29:00 UTC

[jira] [Commented] (IMPALA-6934) Wrong results with EXISTS subquery containing ORDER BY, LIMIT, and OFFSET

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

ASF subversion and git services commented on IMPALA-6934:
---------------------------------------------------------

Commit 9c32594f722f139955788d0da57bdeecc3bacf75 in impala's branch refs/heads/2.x from [~boroknagyz]
[ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=9c32594 ]

IMPALA-6934: Wrong results with EXISTS subquery containing ORDER BY, LIMIT, and OFFSET

Queries may return wrong results if an EXISTS subquery has
an ORDER BY with a LIMIT and OFFSET clause. The EXISTS
subquery may incorrectly evaluate to TRUE even though it is
FALSE.

The bug was found during the code review of IMPALA-6314
(https://gerrit.cloudera.org/#/c/9005/). Turned out
QueryStmt.setLimit() wipes the offset. I modified it to
keep the offset expr.

Added tests to 'PlannerTest/subquery-rewrite.test' and
'QueryTest/subquery.test'

Change-Id: I9693623d3d0a8446913261252f8e4a07935645e0
Reviewed-on: http://gerrit.cloudera.org:8080/10218
Reviewed-by: Alex Behm <al...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Wrong results with EXISTS subquery containing ORDER BY, LIMIT, and OFFSET
> -------------------------------------------------------------------------
>
>                 Key: IMPALA-6934
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6934
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 2.5.0, Impala 2.6.0, Impala 2.7.0, Impala 2.8.0, Impala 2.9.0, Impala 2.10.0, Impala 2.11.0, Impala 2.12.0
>            Reporter: Alexander Behm
>            Assignee: Zoltán Borók-Nagy
>            Priority: Blocker
>              Labels: correctness, planner
>
> Queries may return wrong results if an EXISTS subquery has an ORDER BY with a LIMIT and OFFSET clause. The EXISTS subquery may incorrectly evaluate to TRUE even though it s FALSE.
> Reproduction:
> {code}
> select count(*) from functional.alltypestiny t where
> exists (select id from functional.alltypestiny where id < 5 order by id limit 10 offset 6);
> {code}
> The query should return "0" but it incorrectly returns "8" because an incorrect plan without the offset is generated. See plan:
> {code}
> +-------------------------------------------------+
> | Explain String                                  |
> +-------------------------------------------------+
> | Max Per-Host Resource Reservation: Memory=0B    |
> | Per-Host Resource Estimates: Memory=84.00MB     |
> | Codegen disabled by planner                     |
> |                                                 |
> | PLAN-ROOT SINK                                  |
> | |                                               |
> | 08:AGGREGATE [FINALIZE]                         |
> | |  output: count:merge(*)                       |
> | |                                               |
> | 07:EXCHANGE [UNPARTITIONED]                     |
> | |                                               |
> | 04:AGGREGATE                                    |
> | |  output: count(*)                             |
> | |                                               |
> | 03:NESTED LOOP JOIN [LEFT SEMI JOIN, BROADCAST] |
> | |                                               |
> | |--06:EXCHANGE [BROADCAST]                      |
> | |  |                                            |
> | |  05:MERGING-EXCHANGE [UNPARTITIONED]          |
> | |  |  order by: id ASC                          |
> | |  |  limit: 1                                  |
> | |  |                                            |
> | |  02:TOP-N [LIMIT=1]                           |
> | |  |  order by: id ASC                          |
> | |  |                                            |
> | |  01:SCAN HDFS [functional.alltypestiny]       |
> | |     partitions=4/4 files=4 size=460B          |
> | |     predicates: id < 5                        |
> | |                                               |
> | 00:SCAN HDFS [functional.alltypestiny t]        |
> |    partitions=4/4 files=4 size=460B             |
> +-------------------------------------------------+
> {code}
> Evaluating the subquery by itself gives the expected results:
> {code}
> select id from functional.alltypestiny where id < 5 order by id limit 10 offset 6;
> <empty result set>
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org