zhztheplayer commented on code in PR #13697:
URL: https://github.com/apache/gluten/pull/13697#discussion_r4802510963
##########
gluten-core/src/main/scala/org/apache/spark/sql/errors/NativeErrorTranslator.scala:
##########
@@ -16,14 +16,22 @@
*/
package org.apache.spark.sql.errors
-import org.apache.spark.{QueryContext, SparkRuntimeException}
+import org.apache.gluten.exception.GlutenNativeException
+
+import org.apache.spark.{QueryContext, SparkArithmeticException,
SparkRuntimeException}
import org.apache.spark.internal.Logging
import
org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException
+import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.util.SparkVersionUtil
/**
- * Translates native errors into the matching Spark exceptions. An error is
recognized by the first
- * non-null message in its cause chain.
+ * Translates native errors into the matching Spark exceptions.
+ *
+ * The JNI boundary raises a GlutenNativeException for a native error that its
backend describes.
+ * Its error condition is the Spark error condition of the error, for example
"DIVIDE_BY_ZERO".
+ * Errors whose condition is not supported yet, or that have none, fall back
to translation based on
+ * the error message. The message-based translation can be removed for an
error once native code
+ * attaches its condition.
*
* This is for the Velox backend only: the messages it recognizes are Velox's
error messages.
*/
Review Comment:
Maybe out of the topic, but if NativeErrorTranslator is for Velox only, and
it's in `gluten-core`, maybe the design is worth to be revisited for code
quality
##########
docs/developers/NewToGluten.md:
##########
@@ -134,8 +134,9 @@ exception is left untouched; failure to throw the fallback
is logged.
A backend can register a `JniExceptionMetadataRegistration` to describe its own
native errors to Java. The boundary asks the registered providers only when no
Java exception is pending or carried. Providers must not call JNI; they return
-the backend's name for the function that failed, the error's reason and its
-diagnostic as owned strings. The function name can differ from the name of the
+the backend's name for the function that failed, the error's reason, its
+diagnostic and, if it has one, its Spark error condition (such as
+`DIVIDE_BY_ZERO`) as owned strings. The function name can differ from the name
of the
Review Comment:
I found this doc section is barely readable by human but maybe it's only me
who lacks some patience here
https://github.com/Abhinav-Agarwal021/gluten/blob/7ffed324b37370e9aadd2690e6f749fba4c4b481/docs/developers/NewToGluten.md?plain=1#L100-L183
Maybe we can replace the long text with brief explanation + some examples,
cc @felipepessoto
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]