impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Behm (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-5030: Adds support for NVL2() function
Date Wed, 24 May 2017 18:12:34 GMT
Alex Behm has posted comments on this change.

Change subject: IMPALA-5030: Adds support for NVL2() function

Patch Set 2:

Commit Message:

Line 11: expr3.
Briefly mention that NVL2() is converted to IF before analysis.
File fe/src/main/java/org/apache/impala/analysis/

Line 94:     if (fnName.getFnNamePath().get(0).equalsIgnoreCase("nvl2")) {
Please follow the same checks as above for "decode". You could have:
SELECT _impala_builtins.NVL2() ...

Line 95:       Preconditions.checkArgument(params.size()==3, "NVL2() "
Preconditions checks are like asserts. They are used to enforce code invariants, i.e., if
one of them is hit it indicates a bug in the code.

I suggest removing this Preconditions check. The analysis of the returned IF FunctionCallExpr
will handle checking the number of arguments.

Line 97:       Preconditions.checkArgument(
Same here, inappropriate use of Preconditions check. In addition, the matchesType() is too
restrictive. We typically add implicit casts when possible to match function signatures.

I think this should simply be removed. The analysis of the IF FunctionCallExpr will deal with
type compatibility and add casts if necessary.
File fe/src/test/java/org/apache/impala/analysis/

Line 1605:     
remove whitespace

Line 1606:     // NVL2() 
mention that NVL2() is converted to IF before analysis

Line 1607:     AnalyzesOk("select nvl2(1, 'not null', 'null')");
Add negative cases to show what error message will be shown, for example:

select nvl2(1, 's', 10)
select nvl2(1, 10);

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I32b03e9864f46c9c5e482280d1aa676ff7f02644
Gerrit-PatchSet: 2
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Vincent Tran <>
Gerrit-Reviewer: Alex Behm <>
Gerrit-HasComments: Yes

View raw message