mirror of https://github.com/apache/druid.git
Fixed NPE in `array_overlap` and `array_contains`. (#17465)
This commit is contained in:
parent
5764183d4e
commit
0dcc2bc469
|
@ -3974,7 +3974,7 @@ public interface Function extends NamedFunction
|
|||
{
|
||||
if (args.get(1).isLiteral()) {
|
||||
final ExpressionType lhsType = args.get(0).getOutputType(inspector);
|
||||
if (lhsType == null) {
|
||||
if (lhsType == null || !(lhsType.isPrimitive() || lhsType.isPrimitiveArray())) {
|
||||
return this;
|
||||
}
|
||||
final ExpressionType lhsArrayType = ExpressionType.asArrayType(lhsType);
|
||||
|
@ -4107,7 +4107,7 @@ public interface Function extends NamedFunction
|
|||
{
|
||||
if (args.get(1).isLiteral()) {
|
||||
final ExpressionType lhsType = args.get(0).getOutputType(inspector);
|
||||
if (lhsType == null) {
|
||||
if (lhsType == null || !(lhsType.isPrimitive() || lhsType.isPrimitiveArray())) {
|
||||
return this;
|
||||
}
|
||||
final ExpressionType lhsArrayType = ExpressionType.asArrayType(lhsType);
|
||||
|
|
|
@ -419,6 +419,22 @@ public class NestedDataExpressionsTest extends InitializedNullHandlingTest
|
|||
eval = expr.eval(inputBindings);
|
||||
Assert.assertEquals(3L, eval.value());
|
||||
Assert.assertEquals(ExpressionType.LONG, eval.type());
|
||||
|
||||
expr = Parser.parse("array_contains(json_query_array(nest, '$.x'), 100)", MACRO_TABLE);
|
||||
expr = expr.asSingleThreaded(inputBindings);
|
||||
Assert.assertEquals(1L, expr.eval(inputBindings).value());
|
||||
|
||||
expr = Parser.parse("array_contains(json_query_array(nest, '$.x'), 101)", MACRO_TABLE);
|
||||
expr = expr.asSingleThreaded(inputBindings);
|
||||
Assert.assertEquals(0L, expr.eval(inputBindings).value());
|
||||
|
||||
expr = Parser.parse("array_overlap(json_query_array(nest, '$.x'), [100, 101])", MACRO_TABLE);
|
||||
expr = expr.asSingleThreaded(inputBindings);
|
||||
Assert.assertEquals(1L, expr.eval(inputBindings).value());
|
||||
|
||||
expr = Parser.parse("array_overlap(json_query_array(nest, '$.x'), [101, 102])", MACRO_TABLE);
|
||||
expr = expr.asSingleThreaded(inputBindings);
|
||||
Assert.assertEquals(0L, expr.eval(inputBindings).value());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue