impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Zeyliger (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-5211: Simplifying ifnull conditional.
Date Mon, 11 Sep 2017 17:48:53 GMT
Hello Matthew Jacobs,

I'd like you to reexamine a change.  Please visit

to look at the new patch set (#6).

Change subject: IMPALA-5211: Simplifying ifnull conditional.

IMPALA-5211: Simplifying ifnull conditional.

Re-writes ifnull(x, y) into if(x IS DISTINCT FROM y, x, NULL),
and simplifies x IS DISTINCT FROM y -> FALSE if x.equals(y). Removes
backend implementation of ifnull.

It's important and subtle that the re-write uses "x IS DISTINCT FROM y"
rather than "x != y" so that the simplification can be made while
handling null values correctly. ("x != x" may be either false or null,
but x is distinct from x is always false.)

The error messages are slightly altered by this change:


  Query: select nullif("a", 1)
  ERROR: AnalysisException: No matching function with signature: nullif(STRING, TINYINT).

  Query: select nullif(1, 2, 3)
  ERROR: AnalysisException: No matching function with signature: nullif(TINYINT, TINYINT,


  ERROR: AnalysisException: operands of type STRING and TINYINT are not comparable: 'a' IS
  ERROR: AnalysisException: nullif() must be called with two arguments.

This kind of error message is consistent with what you get for other re-writes.

* Added new tests to ExprRewriteRulesTests for nullif and the if(x
  distinct from y, ...) simplification.
* New test for the rewrite in ParserTest.
* Adds an nvl2() test, incidentally.
* Confirmed (using EclEmma, which uses jococo engine) that coverage is good.
* Ran the tests.

Change-Id: Id91ca968a0c0be44e1ec54ad8602f91a5cb2e0e5
M be/src/exprs/
M be/src/exprs/
M be/src/exprs/conditional-functions.h
M be/src/exprs/
M be/src/exprs/scalar-expr.h
M common/function-registry/
M fe/src/main/java/org/apache/impala/analysis/
M fe/src/main/java/org/apache/impala/analysis/
M fe/src/main/java/org/apache/impala/rewrite/
A fe/src/main/java/org/apache/impala/rewrite/
M fe/src/test/java/org/apache/impala/analysis/
M fe/src/test/java/org/apache/impala/analysis/
12 files changed, 195 insertions(+), 93 deletions(-)

  git pull ssh:// refs/changes/29/7829/6
To view, visit
To unsubscribe, visit

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id91ca968a0c0be44e1ec54ad8602f91a5cb2e0e5
Gerrit-PatchSet: 6
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Philip Zeyliger <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-Reviewer: Matthew Jacobs <>
Gerrit-Reviewer: Philip Zeyliger <>

View raw message