Skip to content

Apache DataFusion SQL Query Engine

Moved nullif out of unary (#3241)

compheadc574269a0f71
diff --git a/datafusion/expr/src/expr_fn.rs b/datafusion/expr/src/expr_fn.rs
index 9b51273a0f..adae10e224 100644
--- a/datafusion/expr/src/expr_fn.rs
+++ b/datafusion/expr/src/expr_fn.rs
@@ -324,7 +324,7 @@ unary_scalar_expr!(Exp, exp, "base 2 logarithm");
unary_scalar_expr!(Log2, log2, "base 10 logarithm");
unary_scalar_expr!(Log10, log10, "base 10 logarithm");
unary_scalar_expr!(Ln, ln, "natural logarithm");
-unary_scalar_expr!(NullIf, nullif, "The NULLIF function returns a null value if value1 equals value2; otherwise it returns value1. This can be used to perform the inverse operation of the COALESCE expression."); //TODO this is not a unary expression https://github.com/apache/arrow-datafusion/issues/3069
+scalar_expr!(NullIf, nullif, arg_1, arg_2);
scalar_expr!(Power, power, base, exponent);
scalar_expr!(Atan2, atan2, y, x);
diff --git a/datafusion/proto/src/from_proto.rs b/datafusion/proto/src/from_proto.rs
index ca22eb436b..63d9fe2b79 100644
--- a/datafusion/proto/src/from_proto.rs
+++ b/datafusion/proto/src/from_proto.rs
@@ -1015,7 +1015,10 @@ pub fn parse_expr(
ScalarFunction::Sha384 => Ok(sha384(parse_expr(&args[0], registry)?)),
ScalarFunction::Sha512 => Ok(sha512(parse_expr(&args[0], registry)?)),
ScalarFunction::Md5 => Ok(md5(parse_expr(&args[0], registry)?)),
- ScalarFunction::NullIf => Ok(nullif(parse_expr(&args[0], registry)?)),
+ ScalarFunction::NullIf => Ok(nullif(
+ parse_expr(&args[0], registry)?,
+ parse_expr(&args[1], registry)?,
+ )),
ScalarFunction::Digest => Ok(digest(
parse_expr(&args[0], registry)?,
parse_expr(&args[1], registry)?,