gianm commented on code in PR #15974:
URL: https://github.com/apache/druid/pull/15974#discussion_r1509516323
##########
processing/src/main/java/org/apache/druid/math/expr/Function.java:
##########
@@ -3803,16 +3854,56 @@ 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 List<Object> array2 = Arrays.asList(rhsExpr.asArray());
+ 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) {
+ return ExprEval.ofLong(null);
Review Comment:
This makes me wonder what happens when the rhs array includes null.
Consider `MV_CONTAINS(x, ARRAY[NULL, 'abc', 'def'])`, when `x` is a MVD
where one row contains a single `NULL`. Is that equivalent to `x IS NULL OR
MV_CONTAINS(x, ARRAY['abc', 'def'])` (which returns `TRUE`) or is it equivalent
to `MV_CONTAINS(x, ARRAY['abc', 'def'])`?
For that matter, consider `MV_CONTAINS(x, ARRAY['abc', 'def'])` in the same
situation. Does it return `FALSE` as if `x` was treated like `ARRAY[NULL]` (a
nonnull array containing null)? Or does it return `UNKNOWN` as if `x` was
`NULL` itself?
Do the answers to these questions depend on how the `MV_CONTAINS` is
planned— whether it ends up as an `array_contains` or a filter or something
else?
--
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]