liuyongvs commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1225139247
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -471,6 +471,34 @@ public static SqlOperandTypeChecker variadic(
.or(OperandTypes.family(SqlTypeFamily.MAP))
.or(OperandTypes.family(SqlTypeFamily.ANY));
+ public static final SqlOperandTypeChecker
STRING_OR_BINARY_ARRAY_STRING_OPTIONAL_STRING =
+ new FamilyOperandTypeChecker(
+ ImmutableList.of(SqlTypeFamily.ARRAY, SqlTypeFamily.STRING,
SqlTypeFamily.STRING),
+ i -> i == 2) {
+ @SuppressWarnings("argument.type.incompatible")
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+ if (!super.checkOperandTypes(callBinding, throwOnFailure)) {
+ return false;
+ }
+ RelDataType elementType =
callBinding.getOperandType(0).getComponentType();
+ if (elementType == null ||
(!SqlTypeFamily.STRING.contains(elementType)
+ && !SqlTypeFamily.BINARY.contains(elementType))) {
+ if (throwOnFailure) {
Review Comment:
if i understand correct, it can use SqlTypeUtil.isString.
string familiy has 4 type
public static final List<SqlTypeName> CHAR_TYPES =
ImmutableList.of(CHAR, VARCHAR);
public static final List<SqlTypeName> BINARY_TYPES =
ImmutableList.of(BINARY, VARBINARY);
--
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]