Yicong-Huang commented on code in PR #54362:
URL: https://github.com/apache/spark/pull/54362#discussion_r2839328648


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/python/streaming/PythonStreamingDataSourceSuite.scala:
##########
@@ -444,13 +444,15 @@ class PythonStreamingDataSourceSimpleSuite extends 
PythonDataSourceSuiteBase {
     }
     assert(err.getCause.isInstanceOf[SparkException])
     val cause = err.getCause.asInstanceOf[SparkException]
+    // SPARK-55583: Python streaming data source wraps all Python exceptions as
+    // PYTHON_STREAMING_DATA_SOURCE_RUNTIME_ERROR. The underlying schema 
mismatch
+    // error (DATA_SOURCE_RETURN_SCHEMA_MISMATCH) is preserved in the message.
     checkErrorMatchPVals(
       cause,
-      condition = "ARROW_TYPE_MISMATCH",
+      condition = "PYTHON_STREAMING_DATA_SOURCE_RUNTIME_ERROR",
       parameters = Map(
-        "operation" -> "Python streaming data source read",
-        "outputTypes" -> 
"StructType\\(StructField\\(id,IntegerType,false\\)\\)",
-        "actualDataTypes" -> 
"StructType\\(StructField\\(id,StringType,true\\)\\)"
+        "action" -> "planPartitions",
+        "msg" -> "(?s).*DATA_SOURCE_RETURN_SCHEMA_MISMATCH.*"

Review Comment:
   the full message would look like 
   ```
     [PYTHON_STREAMING_DATA_SOURCE_RUNTIME_ERROR]
     Failed when Python streaming data source perform planPartitions:
     PySparkRuntimeError: [DATA_SOURCE_RETURN_SCHEMA_MISMATCH]
     Return schema mismatch in the result from 'read' method.
     Expected: <expected_schema>, Found: <actual_schema>
   ```
   
   Yes, the error contains two error classes. The outer 
`PYTHON_STREAMING_DATA_SOURCE_RUNTIME_ERROR` wraps the inner 
`DATA_SOURCE_RETURN_SCHEMA_MISMATCH` error.  We use a general outer class to 
provide consistent error handling across all operations in streaming, while 
preserving the original Python error message for debugging.



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

Reply via email to