clintropolis commented on code in PR #15974:
URL: https://github.com/apache/druid/pull/15974#discussion_r1504686302
##########
processing/src/main/java/org/apache/druid/math/expr/Function.java:
##########
@@ -3779,15 +3781,55 @@ public ExpressionType
getOutputType(Expr.InputBindingInspector inspector, List<E
}
@Override
- ExprEval doApply(ExprEval lhsExpr, ExprEval rhsExpr)
+ public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
{
- final Object[] array1 = lhsExpr.asArray();
- final Object[] array2 = rhsExpr.asArray();
- return
ExprEval.ofLongBoolean(Arrays.asList(array1).containsAll(Arrays.asList(array2)));
+ final ExprEval arrayExpr1 = args.get(0).eval(bindings);
+ final ExprEval arrayExpr2 = args.get(1).eval(bindings);
+
+ final Object[] array1 = arrayExpr1.asArray();
+ final Object[] array2 = arrayExpr2.asArray();
+ if (array1 == null) {
Review Comment:
this function already returned null, though in a non-obvious way. Both of
these functions were previously extending the `ArraysFunction` base class,
which is mostly intended for stuff like `array_append` and such to do stuff to
two array arguments, and has sections like this for when the arguments were null
```
if (arrayExpr1.asArray() == null) {
return arrayExpr1;
}
```
but weren't really returning the standardized long boolean type. The other
problem with extending this, is that for something like array_contains, that
second check for a null argument meant there was no way to check if the null
element was present in an array.
So anyway, that is what i meant by 'correctly return null', they return LONG
null instead of whatever array type null, so that the return type is always
consistently LONG
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]