diff --git a/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java b/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java index 6d4228d1f88..8abb7c81785 100644 --- a/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java +++ b/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java @@ -1231,10 +1231,6 @@ private static class MapFromEntriesOperandTypeChecker /** * Operand type-checking strategy for a ARRAY function, it allows empty array. - * - *
The reason it overrides SameOperandTypeChecker#checkOperandTypesImpl is that it needs - * to handle the scenario where row/struct type and NULL exist simultaneously in array. - * This scenario need be supported, but will be rejected by the current checkOperandTypesImpl. */ private static class ArrayFunctionOperandTypeChecker extends SameOperandTypeChecker { @@ -1264,15 +1260,14 @@ private static class ArrayFunctionOperandTypeChecker for (int i : operandList) { types[i] = operatorBinding.getOperandType(i); } - int prev = -1; for (int i : operandList) { - if (prev >= 0) { + if (i > 0) { // we replace SqlTypeUtil.isComparable with SqlTypeUtil.leastRestrictiveForComparison // to handle struct type and NULL constant. // details please see: https://issues.apache.org/jira/browse/CALCITE-6163 RelDataType type = SqlTypeUtil.leastRestrictiveForComparison(operatorBinding.getTypeFactory(), - types[i], types[prev]); + types[i], types[i - 1]); if (type == null) { if (!throwOnFailure) { return false; @@ -1281,7 +1276,6 @@ private static class ArrayFunctionOperandTypeChecker RESOURCE.needSameTypeParameter()); } } - prev = i; } return true; }