liuyongvs commented on code in PR #3238:
URL: https://github.com/apache/calcite/pull/3238#discussion_r1218855652
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -944,6 +944,31 @@ private static RelDataType
arrayReturnType(SqlOperatorBinding opBinding) {
ReturnTypes.TO_MAP_VALUES_NULLABLE,
OperandTypes.MAP);
+ private static RelDataType mapReturnType(SqlOperatorBinding opBinding) {
+ final RelDataType keysArrayType = opBinding.collectOperandTypes().get(0);
+ final RelDataType valuesArrayType = opBinding.collectOperandTypes().get(1);
+ final boolean nullable = keysArrayType.isNullable() ||
valuesArrayType.isNullable();
+ return SqlTypeUtil.createMapType(
+ opBinding.getTypeFactory(),
+ requireNonNull(keysArrayType.getComponentType(), "inferred key type"),
+ requireNonNull(valuesArrayType.getComponentType(), "inferred value
type"),
+ nullable);
+ }
+
+ /** The "MAP_FROM_ARRAYS(keysArray, valuesArray)" function. */
+ @LibraryOperator(libraries = {SPARK})
+ public static final SqlFunction MAP_FROM_ARRAYS =
+ SqlBasicFunction.create(SqlKind.MAP_FROM_ARRAYS,
+ SqlLibraryOperators::mapReturnType,
+ OperandTypes.ARRAY_ARRAY);
+
+ /** The "STR_TO_MAP(string[, stringDelimiter[, keyValueDelimiter]])"
function. */
+ @LibraryOperator(libraries = {SPARK})
+ public static final SqlFunction STR_TO_MAP =
+ SqlBasicFunction.create(SqlKind.STR_TO_MAP,
Review Comment:
fixed @tanclary define STRING_OPTIONAL_STRING_OPTIONAL_STRING
--
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]