diff --git a/core/src/main/java/org/apache/spark/SparkThrowable.java b/core/src/main/java/org/apache/spark/SparkThrowable.java index 2be0c3c0f9466..581e1f6eebb8b 100644 --- a/core/src/main/java/org/apache/spark/SparkThrowable.java +++ b/core/src/main/java/org/apache/spark/SparkThrowable.java @@ -36,6 +36,10 @@ public interface SparkThrowable { // If null, error class is not set String getErrorClass(); + default String getErrorSubClass() { + return null; + } + // Portable error identifier across SQL engines // If null, error class or SQLSTATE is not set default String getSqlState() { @@ -46,4 +50,13 @@ default String getSqlState() { default boolean isInternalError() { return SparkThrowableHelper.isInternalError(this.getErrorClass()); } + + default String[] getMessageParameters() { + return new String[]{}; + } + + // Returns a string array of all parameters that need to be passed to this error message. + default String[] getParameterNames() { + return SparkThrowableHelper.getParameterNames(this.getErrorClass(), this.getErrorSubClass()); + } } diff --git a/core/src/main/java/org/apache/spark/memory/SparkOutOfMemoryError.java b/core/src/main/java/org/apache/spark/memory/SparkOutOfMemoryError.java index c5f19a0c2012b..9d2739018a038 100644 --- a/core/src/main/java/org/apache/spark/memory/SparkOutOfMemoryError.java +++ b/core/src/main/java/org/apache/spark/memory/SparkOutOfMemoryError.java @@ -39,11 +39,17 @@ public SparkOutOfMemoryError(OutOfMemoryError e) { } public SparkOutOfMemoryError(String errorClass, String[] messageParameters) { - super(SparkThrowableHelper.getMessage(errorClass, messageParameters, "")); + super(SparkThrowableHelper.getMessage(errorClass, null, + messageParameters, "")); this.errorClass = errorClass; this.messageParameters = messageParameters; } + @Override + public String[] getMessageParameters() { + return messageParameters; + } + @Override public String getErrorClass() { return errorClass; diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 59553e78d74ab..833ecc0a3c09e 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -31,19 +31,19 @@ }, "CANNOT_UP_CAST_DATATYPE" : { "message" : [ - "Cannot up cast from to .", + "Cannot up cast from to .", "
" ] }, "CAST_INVALID_INPUT" : { "message" : [ - "The value of the type cannot be cast to because it is malformed. Correct the value as per the syntax, or change its target type. Use `try_cast` to tolerate malformed input and return NULL instead. If necessary set to \"false\" to bypass this error." + "The value of the type cannot be cast to because it is malformed. Correct the value as per the syntax, or change its target type. Use `try_cast` to tolerate malformed input and return NULL instead. If necessary set to \"false\" to bypass this error." ], "sqlState" : "42000" }, "CAST_OVERFLOW" : { "message" : [ - "The value of the type cannot be cast to due to an overflow. Use `try_cast` to tolerate overflow and return NULL instead. If necessary set to \"false\" to bypass this error." + "The value of the type cannot be cast to due to an overflow. Use `try_cast` to tolerate overflow and return NULL instead. If necessary set to \"false\" to bypass this error." ], "sqlState" : "22005" }, @@ -83,7 +83,7 @@ }, "FORBIDDEN_OPERATION" : { "message" : [ - "The operation is not allowed on : " + "The operation is not allowed on the : " ] }, "GRAPHITE_SINK_INVALID_PROTOCOL" : { @@ -157,8 +157,7 @@ "See more details in SPARK-31404. You can set the SQL config or", "the datasource option