julianhyde commented on code in PR #2819:
URL: https://github.com/apache/calcite/pull/2819#discussion_r1000994647


##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -721,4 +738,31 @@ boolean canImplicitTypeCast(List<RelDataType> types, 
List<SqlTypeFamily> familie
     }
     return null;
   }
+
+  /**
+   * Coerce STRING type to ARRAY type.
+   */
+  protected Boolean coerceStringToArray(
+      SqlCall call,
+      SqlNode operand,
+      int index,
+      RelDataType fromType,
+      RelDataType targetType) {
+    if (validator.config().conformance().allowCoercionStringToArray()
+        && SqlTypeUtil.isString(fromType)
+        && SqlTypeUtil.isArray(targetType)
+        && operand instanceof SqlCharStringLiteral
+    ) {
+      try {
+        SqlNode arrayValue = SqlParserUtil.parseArrayLiteral(
+            ((SqlCharStringLiteral) operand).getValueAs(String.class));
+        call.setOperand(index, arrayValue);
+        updateInferredType(arrayValue, targetType);
+      } catch (Throwable e) {
+        return false;

Review Comment:
   Yes, `catch Error` is just as bad as `catch Throwable`.
   
   Is it possible for `parseArrayLiteral` to declare a short list of exceptions 
that it may throw? Some of them will be user errors (i.e. the string is not 
valid format); internal errors (e.g. `NullPointerException`, 
`ArrayIndexOutOfBoundsException`) should be rethrown, not become `return false`.



-- 
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-unsubscr...@calcite.apache.org

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

Reply via email to