Xuebin Su has uploaded a new patch set (#2). ( 
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 new aggregate function called
`aggif_init_zero()`, whose behavior is almost the same as `aggif()`
except that the initial value is set to 0 instead of NULL so that if no
row satisfies its predicate, it will return 0 instead of NULL.

Currently `aggif_init_zero()` is used for `count()` and `ndv()` in the
PIVOT clause. Other aggregate functions that do not return NULL on empty
tables are not supported.

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

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

Change-Id: Idae4a510dd3d6c4cd16a3e03aa0161ad84863e5a
---
M be/src/exprs/aggregate-functions-ir.cc
M be/src/exprs/aggregate-functions.h
M fe/src/main/java/org/apache/impala/analysis/PivotTableRef.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
6 files changed, 69 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/25/24325/2
--
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: 2
Gerrit-Owner: Xuebin Su <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>

Reply via email to