You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "tanclary (via GitHub)" <gi...@apache.org> on 2023/07/19 14:53:52 UTC

[GitHub] [calcite] tanclary commented on a diff in pull request #3324: [CALCITE-5862] Incorrect spark semantics of array function when elements have Numeric and Character types

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


##########
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) {

Review Comment:
   can this be rewritten as a switch case?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org