xuzifu666 commented on code in PR #5042:
URL: https://github.com/apache/calcite/pull/5042#discussion_r3465150979
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1763,23 +1763,32 @@ private static RelDataType
deriveTypeArraysZip(SqlOperatorBinding opBinding) {
OperandTypes.ARRAY.or(OperandTypes.ARRAY_BOOLEAN_LITERAL));
private static RelDataType deriveTypeMapConcat(SqlOperatorBinding opBinding)
{
+ final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
if (opBinding.getOperandCount() == 0) {
- final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
- final RelDataType type = typeFactory.createSqlType(SqlTypeName.VARCHAR);
- requireNonNull(type, "type");
+ final RelDataType type = typeFactory.createSqlType(SqlTypeName.ANY);
return SqlTypeUtil.createMapType(typeFactory, type, type, true);
- } else {
- final List<RelDataType> operandTypes = opBinding.collectOperandTypes();
- for (RelDataType operandType : operandTypes) {
- if (!SqlTypeUtil.isMap(operandType)) {
- throw opBinding.newError(
- RESOURCE.typesShouldAllBeMap(
- opBinding.getOperator().getName(),
- operandType.getFullTypeString()));
- }
+ }
+ final List<RelDataType> operandTypes = opBinding.collectOperandTypes();
+ final List<RelDataType> mapTypes = new ArrayList<>();
+ boolean hasNull = false;
+ for (RelDataType operandType : operandTypes) {
+ if (operandType.getSqlTypeName() == SqlTypeName.NULL) {
+ hasNull = true;
+ } else if (SqlTypeUtil.isMap(operandType)) {
+ mapTypes.add(operandType);
+ } else {
+ throw opBinding.newError(
+ RESOURCE.typesShouldAllBeMap(
+ opBinding.getOperator().getName(),
+ operandType.getFullTypeString()));
}
- return
requireNonNull(opBinding.getTypeFactory().leastRestrictive(operandTypes));
}
+ if (mapTypes.isEmpty() || hasNull) {
+ // All arguments are NULL literals, or at least one argument is a NULL
literal;
Review Comment:
Done
--
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]