chucheng92 commented on code in PR #3459:
URL: https://github.com/apache/calcite/pull/3459#discussion_r1349646490
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1077,6 +1079,38 @@ private static RelDataType
arrayReturnType(SqlOperatorBinding opBinding) {
SqlLibraryOperators::arrayReturnType,
OperandTypes.SAME_VARIADIC);
+ private static RelDataType mapReturnType(SqlOperatorBinding opBinding) {
+ Pair<@Nullable RelDataType, @Nullable RelDataType> type =
+ getComponentTypes(
+ opBinding.getTypeFactory(), opBinding.collectOperandTypes());
+ return SqlTypeUtil.createMapType(
+ opBinding.getTypeFactory(),
+ requireNonNull(type.left, "inferred key type"),
+ requireNonNull(type.right, "inferred value type"),
+ false);
+ }
+
+ private static Pair<@Nullable RelDataType, @Nullable RelDataType>
getComponentTypes(
+ RelDataTypeFactory typeFactory,
+ List<RelDataType> argTypes) {
+ // special case, allows empty map
+ if (argTypes.size() == 0) {
+ return Pair.of(typeFactory.createUnknownType(),
typeFactory.createUnknownType());
Review Comment:
because Spark use VOID type when map is empty, the Spark VOID type are
equivalent in some degree with calcite UNKNOWN.
And it's similar with current spark ARRAY handling. pls see:
https://github.com/apache/calcite/pull/3141/files
--
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]