tanclary commented on code in PR #3324:
URL: https://github.com/apache/calcite/pull/3324#discussion_r1268207510


##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -955,10 +955,38 @@ static RelDataType deriveTypeSplit(SqlOperatorBinding 
operatorBinding,
           .withKind(SqlKind.CONCAT_WS_MSSQL);
 
   private static RelDataType arrayReturnType(SqlOperatorBinding opBinding) {
-    RelDataType type =
-        opBinding.getOperandCount() > 0
-            ? ReturnTypes.LEAST_RESTRICTIVE.inferReturnType(opBinding)
-            : opBinding.getTypeFactory().createUnknownType();
+    // only numeric & character types check
+    List<RelDataType> numericTypes = new ArrayList<>();
+    List<RelDataType> characterTypes = new ArrayList<>();
+    List<RelDataType> nullTypes = new ArrayList<>();
+    for (int i = 0; i < opBinding.getOperandCount(); i++) {
+      SqlTypeFamily family = 
opBinding.getOperandType(i).getSqlTypeName().getFamily();
+      if (family == SqlTypeFamily.NUMERIC) {
+        numericTypes.add(opBinding.getOperandType(i));
+      } else if (family == SqlTypeFamily.CHARACTER) {
+        characterTypes.add(opBinding.getOperandType(i));
+      } else if (family == SqlTypeFamily.NULL) {
+        nullTypes.add(opBinding.getOperandType(i));
+      } else {
+        break;
+      }
+    }
+
+    boolean onlyNumericCharacterTypes = opBinding.getOperandCount() > 0

Review Comment:
   I could be misunderstanding, but if you only care about the size of the 
lists and not the elements themselves, you could just use boolean flags to keep 
track of which types have appeared. I think it will simplify the expression 
below.



-- 
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]

Reply via email to