IMPALA-5030: [DOCS] Document nvl2() function Change-Id: I8497e69d0f6db3c5e17b04e49a875c3efb43fab0 Reviewed-on: http://gerrit.cloudera.org:8080/7365 Reviewed-by: Tim Armstrong <[email protected]> Tested-by: Impala Public Jenkins
Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/bc1feb34 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/bc1feb34 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/bc1feb34 Branch: refs/heads/master Commit: bc1feb34d0df37d38b6c718d65d654637e9bb525 Parents: da89330 Author: John Russell <[email protected]> Authored: Thu Jul 6 14:40:41 2017 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Fri Jul 7 05:50:47 2017 +0000 ---------------------------------------------------------------------- docs/shared/impala_common.xml | 6 +++ docs/topics/impala_conditional_functions.xml | 50 +++++++++++++++++++++++ docs/topics/impala_string_functions.xml | 1 + 3 files changed, 57 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/bc1feb34/docs/shared/impala_common.xml ---------------------------------------------------------------------- diff --git a/docs/shared/impala_common.xml b/docs/shared/impala_common.xml index 4522c9b..8a10c9f 100644 --- a/docs/shared/impala_common.xml +++ b/docs/shared/impala_common.xml @@ -2457,6 +2457,12 @@ flight_num: INT32 SNAPPY DO:83456393 FPO:83488603 SZ:10216514/11474301 each value. </p> + <p rev="2.9.0" id="added_in_290"> + <b>Added in:</b> <keyword keyref="impala290"/> + </p> + <p rev="2.8.0" id="added_in_280"> + <b>Added in:</b> <keyword keyref="impala280"/> + </p> <p rev="2.7.0" id="added_in_270"> <b>Added in:</b> <keyword keyref="impala270"/> </p> http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/bc1feb34/docs/topics/impala_conditional_functions.xml ---------------------------------------------------------------------- diff --git a/docs/topics/impala_conditional_functions.xml b/docs/topics/impala_conditional_functions.xml index 9006a54..889294e 100644 --- a/docs/topics/impala_conditional_functions.xml +++ b/docs/topics/impala_conditional_functions.xml @@ -436,6 +436,56 @@ END</codeblock> </dlentry> + <dlentry id="nvl2" rev="2.9.0 IMPALA-5030"> + + <dt> + <codeph>nvl2(type a, type ifNull, type ifNotNull)</codeph> + </dt> + + <dd> + <indexterm audience="hidden">nvl2() function</indexterm> + <b>Purpose:</b> Enhanced variant of the <codeph>nvl()</codeph> function. Tests an expression + and returns different result values depending on whether it is <codeph>NULL</codeph> or not. + If the first argument is <codeph>NULL</codeph>, returns the second argument. + If the first argument is not <codeph>NULL</codeph>, returns the third argument. + Equivalent to the <codeph>nvl2()</codeph> function from Oracle Database. + <p> + <b>Return type:</b> Same as the first argument value + </p> + <p conref="../shared/impala_common.xml#common/added_in_290"/> + <p conref="../shared/impala_common.xml#common/example_blurb"/> + <p> + The following examples show how a query can use special indicator values + to represent null and not-null expression values. The first example tests + an <codeph>INT</codeph> column and so uses special integer values. + The second example tests a <codeph>STRING</codeph> column and so uses + special string values. + </p> +<codeblock> +select x, nvl2(x, 999, 0) from nvl2_demo; ++------+---------------------------+ +| x | if(x is not null, 999, 0) | ++------+---------------------------+ +| NULL | 0 | +| 1 | 999 | +| NULL | 0 | +| 2 | 999 | ++------+---------------------------+ + +select s, nvl2(s, 'is not null', 'is null') from nvl2_demo; ++------+---------------------------------------------+ +| s | if(s is not null, 'is not null', 'is null') | ++------+---------------------------------------------+ +| NULL | is null | +| one | is not null | +| NULL | is null | +| two | is not null | ++------+---------------------------------------------+ +</codeblock> + </dd> + + </dlentry> + <dlentry rev="1.3.0" id="zeroifnull"> <dt> http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/bc1feb34/docs/topics/impala_string_functions.xml ---------------------------------------------------------------------- diff --git a/docs/topics/impala_string_functions.xml b/docs/topics/impala_string_functions.xml index 60b28fc..5758c52 100644 --- a/docs/topics/impala_string_functions.xml +++ b/docs/topics/impala_string_functions.xml @@ -874,6 +874,7 @@ Returned 1 row(s) in 0.12s</codeblock> string, the expansion is only performed once, instead of applying again to the newly constructed string. </p> + <p conref="../shared/impala_common.xml#common/added_in_290"/> <p conref="../shared/impala_common.xml#common/example_blurb"/> <codeblock>-- Replace one string with another. select replace('hello world','world','earth');
