[Bug] Fix array functions arguments mismatch (#10549)
Currently, we convert array<Int> to array<BigInt> For example, the input array_sum([1, 2, 3]) can match function array_sum(Array<Int>) as well as array_sum(Array<BigInt>). But when a function has more than one argument, the function may be match incorrectly. For example, the input array_contains([1, 2, 3], 2147483648) will match the function array_contains(Array<BigInt>, BigInt), but the correct match should be array_contains(Array<Int>, Int) The correct match should be: array_contains([1, 2, 3], 1) match array_contains(Array<Int>, Int) array_contains([1, 2, 3], 2147483648) match array_contains(Array<Int>, Int) array_contains([2147483648, 2147483649, 2147483650], 2147483648) match array_contains(Array<BigInt>, BigInt) now is: array_contains([1, 2, 3], 1) match array_contains(Array<Int>, Int) array_contains([1, 2, 3], 2147483648) match array_contains(Array<BigInt>, BigInt) array_contains([2147483648, 2147483649, 2147483650], 2147483648) match array_contains(Array<BigInt>, BigInt) And this will cause some trouble. Assume that there are two functions being defined: Int array_functions(Array<Int>, Int) BigInt array_functions(Array<BigInt>, BigInt) And array_functions([1,2,3], 2147483648) will match BigInt array_functions(Array<BigInt>, BigInt), but the result type should not be BigInt, but should be Int.
This commit is contained in:
@ -81,7 +81,8 @@ public class ArrayType extends Type {
|
||||
if (itemType.isNull() || ((ArrayType) t).getItemType().isNull()) {
|
||||
return true;
|
||||
}
|
||||
return Type.isImplicitlyCastable(itemType, ((ArrayType) t).itemType, true)
|
||||
|
||||
return itemType.matchesType(((ArrayType) t).itemType)
|
||||
&& (((ArrayType) t).containsNull || !containsNull);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user