chucheng92 commented on PR #3324:
URL: https://github.com/apache/calcite/pull/3324#issuecomment-1646772176
> I think array must have same type.
>
> You should use `TypeCoercionImpl` to solve your problem.
Hi, Jiajun. thanks for reviewing.
However, this PR does not modify the `SameOperandTypeChecker` constraint of
array. In fact, the current `SameOperandTypeChecker` allows character and
numeric to exist at the same time and passes this restriction. It's just that
inferReturnType does not handle the simultaneous existence of character and
numeric. please see:
```
public static final SqlFunction ARRAY =
SqlBasicFunction.create("ARRAY",
SqlLibraryOperators::arrayReturnType,
OperandTypes.SAME_VARIADIC);
```
https://github.com/apache/calcite/blob/bdfb17029f7e205f895dc3dfd0f37c8ff2520823/core/src/main/java/org/apache/calcite/sql/type/SameOperandTypeChecker.java#L92
The `SameOperandTypeChecker` will handle the special case of character,
which itself allows character and numeric to coexist.
so currently run `select array(1, 2, 'Hi');` can pass the OperandTypeChecker
but with NPE in return type checker. This pr is used to fix the inconsistent
behavior of operandTypeChecker and returnTypeInference. WDYT?
--
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]