mirror of https://github.com/apache/druid.git
Fix issue with empty array converting to string expression instead of string array (#11270)
This commit is contained in:
parent
4ba5738ffb
commit
2bfcee5824
|
@ -378,7 +378,7 @@ public abstract class ExprEval<T>
|
|||
return new String[]{null};
|
||||
} else {
|
||||
if (val != null) {
|
||||
return val.toArray();
|
||||
return new String[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -273,6 +273,16 @@ public class ExprEvalTest extends InitializedNullHandlingTest
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyArrayFromList()
|
||||
{
|
||||
// empty arrays will materialize from JSON into an empty list, which coerce list to array will make into Object[]
|
||||
// make sure we can handle it
|
||||
ExprEval someEmptyArray = ExprEval.bestEffortOf(new ArrayList<>());
|
||||
Assert.assertTrue(someEmptyArray.isArray());
|
||||
Assert.assertEquals(0, someEmptyArray.asArray().length);
|
||||
}
|
||||
|
||||
private void assertExpr(int position, Object expected)
|
||||
{
|
||||
assertExpr(position, ExprEval.bestEffortOf(expected));
|
||||
|
|
Loading…
Reference in New Issue