mihaibudiu commented on code in PR #3847:
URL: https://github.com/apache/calcite/pull/3847#discussion_r1676975122
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -1491,6 +1496,43 @@ private static class PeriodOperandTypeChecker
}
}
+ /**
+ * Parameter type-checking strategy where types must be Map
+ * and adjust their types to suit the Map function's constructor.
+ */
+ private static class MapSparkFunctionOperandTypeChecker extends
SameOperandTypeChecker {
+ MapSparkFunctionOperandTypeChecker() {
+ super(1);
+ }
+
+ @Override public boolean checkOperandTypes(
+ SqlCallBinding callBinding,
+ boolean throwOnFailure) {
+
+ final SqlNode op0 = callBinding.operand(0);
+ if (!OperandTypes.MAP.checkSingleOperandType(
+ callBinding,
+ op0,
+ 0,
+ throwOnFailure)) {
+ return false;
+ }
+
+ final RelDataType mapKeyType =
+ getKeyTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+ final RelDataType mapValueType =
+ getValueTypeOrThrow(SqlTypeUtil.deriveType(callBinding, op0));
+
+ // If the key and value types are not unknown,
+ // adjust their types to suit the Map function's constructor.
+ if (mapKeyType.getSqlTypeName() != SqlTypeName.UNKNOWN
Review Comment:
As Julian said in the Jira comments, you should insert casts during
validation, before type checking.
--
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]