Minghui Zhu has uploaded a new patch set (#5). ( 
http://gerrit.cloudera.org:8080/19768 )

Change subject: IMPALA-12051: Propagate analytic tuple predicates of 
outer-joined InlineView
......................................................................

IMPALA-12051: Propagate analytic tuple predicates of outer-joined InlineView

In some cases, direct pushing down predicates that reference analytic
tuple into inline view leads to incorrect query results. While pushing
down analytic predicates (e.g. row_number() < 10), we should also divide
them into two groups. Some of them can be migrated into the view so are
removed in the current scope. Some of them can be copied into the view
but still need to be evaluated in the current scope. The bug is due to
we migrate all of them into the view.

Such as sql:
WITH detail_measure AS (
  SELECT
    *
  FROM
    (
      VALUES
        (
          1 AS `isqbiuar`,
          1 AS `bgsfrbun`,
          1 AS `result_type`,
          1 AS `bjuzzevg`
        ),
        (2, 2, 2, 2)
    ) a
),
order_measure_sql0 AS (
  SELECT
    row_number() OVER (
      ORDER BY
        row_number_0 DESC NULLS LAST,
        isqbiuar ASC NULLS LAST
    ) AS `row_number_0`,
    `isqbiuar`
  FROM
    (
      VALUES
        (1 AS `row_number_0`, 1 AS `isqbiuar`),
        (2, 2)
    ) b
)
SELECT
  detail_measure.`isqbiuar` AS `isqbiuar`,
  detail_measure.`bgsfrbun` AS `bgsfrbun`,
  detail_measure.`result_type` AS `result_type`,
  detail_measure.`bjuzzevg` AS `bjuzzevg`,
  `row_number_0` AS `row_number_0`
FROM
  detail_measure
  LEFT JOIN order_measure_sql0
  ON order_measure_sql0.isqbiuar = detail_measure.isqbiuar
WHERE
  row_number_0 BETWEEN 1
  AND 1
ORDER BY
  `row_number_0` ASC NULLS LAST,
  `bgsfrbun` ASC NULLS LAST

The current query result is:
+----------+----------+-------------+----------+--------------+
| isqbiuar | bgsfrbun | result_type | bjuzzevg | row_number_0 |
+----------+----------+-------------+----------+--------------+
| 2        | 2        | 2           | 2        | 1            |
| 1        | 1        | 1           | 1        | NULL         |
+----------+----------+-------------+----------+--------------+

The correct query result is:
+----------+----------+-------------+----------+--------------+
| isqbiuar | bgsfrbun | result_type | bjuzzevg | row_number_0 |
+----------+----------+-------------+----------+--------------+
| 2        | 2        | 2           | 2        | 1            |
+----------+----------+-------------+----------+--------------+

Tests:
* Add plan tests in analytic-rank-pushdown.test
* Add e2e tests in analytic-fns.test

Change-Id: If6c209b2a64bad37d893ba8b520342bf1f9a7513
---
M fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java
M 
testdata/workloads/functional-planner/queries/PlannerTest/analytic-rank-pushdown.test
M testdata/workloads/functional-query/queries/QueryTest/analytic-fns.test
3 files changed, 552 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/68/19768/5
--
To view, visit http://gerrit.cloudera.org:8080/19768
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If6c209b2a64bad37d893ba8b520342bf1f9a7513
Gerrit-Change-Number: 19768
Gerrit-PatchSet: 5
Gerrit-Owner: Minghui Zhu <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Michael Smith <[email protected]>
Gerrit-Reviewer: Minghui Zhu <[email protected]>
Gerrit-Reviewer: Qifan Chen <[email protected]>
Gerrit-Reviewer: Quanlong Huang <[email protected]>
Gerrit-Reviewer: Tim Armstrong <[email protected]>
Gerrit-Reviewer: Wenzhe Zhou <[email protected]>
Gerrit-Reviewer: Xianqing He <[email protected]>

Reply via email to