rubenada commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1224342705
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -471,6 +471,57 @@ public static SqlOperandTypeChecker variadic(
.or(OperandTypes.family(SqlTypeFamily.MAP))
.or(OperandTypes.family(SqlTypeFamily.ANY));
+ public static final SqlOperandTypeChecker
ARRAY_OF_STRING_OR_BINARY_STRING_STRING_OPTIONAL_STRING
Review Comment:
I'd suggst to try to reuse the FamilyOperandTypeChecker (adding just the
relevant code to check the array component type). Proposal (unverified):
```
public static final SqlOperandTypeChecker
STRING_ARRAY_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
new FamilyOperandTypeChecker(
ImmutableList.of(SqlTypeFamily.ARRAY, SqlTypeFamily.STRING,
SqlTypeFamily.STRING),
i -> i == 2) {
@Override public boolean checkOperandTypes(
SqlCallBinding callBinding,
boolean throwOnFailure) {
if (!super.checkOperandTypes(callBinding, throwOnFailure)) {
return false;
}
RelDataType arrayType =
callBinding.getOperandType(0).getComponentType();
if (arrayType == null || (!SqlTypeFamily.STRING.contains(arrayType)
&& !SqlTypeFamily.BINARY.contains(arrayType))) {
if (throwOnFailure) {
throw callBinding.newValidationSignatureError();
}
return false;
}
return true;
}
};
```
Regarding the checker framework error, if you cannot get rid of it, you can
use `@SuppressWarnings("argument.type.incompatible")` .
If I am not mistaken, you should be able to run it locally in your dev
environment via
`gradlew build -x test -PenableCheckerframework`
--
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]