Xuebin Su has uploaded a new patch set (#8). ( 
http://gerrit.cloudera.org:8080/24325 )

Change subject: IMPALA-15013: Fix NULL issues for PIVOT
......................................................................

IMPALA-15013: Fix NULL issues for PIVOT

Previously, the PIVOT operation returned NULL instead of 0 for `count()`
when no row matches the value. This was because the `aggif()` function
it used returns NULL when its predicate is never satisfied.

This patch fixes the issue by adding a `ifnull()` call on the output of
`aggif()` so that a non-NULL value can be returned based on the return
type of the original aggregate function. For `count()`, 0 will be
returned in this case since its return type is BIGINT.

To support specifying the NULL literal in the PIVOT clause, this patch
changes to using the `IsNullPredicate` instead of the `BinaryPredicate`
in the `aggif()` calls.

This patch also changes `returnsNonNullOnEmpty` to true when creating
the `aggif()` and the `appx_median()` functions to match the actual
behavior.

Testing:
- Added E2E tests for NULL cases.
- Added AnalyzeStmtsTests for unsupported aggregate functions.

Change-Id: Idae4a510dd3d6c4cd16a3e03aa0161ad84863e5a
---
M fe/src/main/java/org/apache/impala/analysis/NumericLiteral.java
M fe/src/main/java/org/apache/impala/analysis/PivotTableRef.java
M fe/src/main/java/org/apache/impala/analysis/StringLiteral.java
M fe/src/main/java/org/apache/impala/catalog/AggregateFunction.java
M fe/src/main/java/org/apache/impala/catalog/BuiltinsDb.java
M fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java
M testdata/workloads/functional-query/queries/QueryTest/pivot-clause.test
7 files changed, 98 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/25/24325/8
--
To view, visit http://gerrit.cloudera.org:8080/24325
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Idae4a510dd3d6c4cd16a3e03aa0161ad84863e5a
Gerrit-Change-Number: 24325
Gerrit-PatchSet: 8
Gerrit-Owner: Xuebin Su <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Kurt Deschler <[email protected]>
Gerrit-Reviewer: Quanlong Huang <[email protected]>
Gerrit-Reviewer: Steve Carlin <[email protected]>
Gerrit-Reviewer: Xuebin Su <[email protected]>

Reply via email to