dongjoon-hyun commented on a change in pull request #29951:
URL: https://github.com/apache/spark/pull/29951#discussion_r500663540



##########
File path: python/pyspark/sql/pandas/serializers.py
##########
@@ -153,13 +153,16 @@ def create_array(s, t):
                 s = s.astype(s.dtypes.categories.dtype)
             try:
                 array = pa.Array.from_pandas(s, mask=mask, type=t, 
safe=self._safecheck)
-            except pa.ArrowException as e:
-                error_msg = "Exception thrown when converting pandas.Series 
(%s) to Arrow " + \
-                            "Array (%s). It can be caused by overflows or 
other unsafe " + \
-                            "conversions warned by Arrow. Arrow safe type 
check can be " + \
-                            "disabled by using SQL config " + \
-                            
"`spark.sql.execution.pandas.convertToArrowArraySafely`."
-                raise RuntimeError(error_msg % (s.dtype, t), e)
+            except ValueError as e:
+                if self._safecheck:
+                    error_msg = "Exception thrown when converting 
pandas.Series (%s) to " + \
+                                "Arrow Array (%s). It can be caused by 
overflows or other " + \
+                                "unsafe conversions warned by Arrow. Arrow 
safe type check " + \
+                                "can be disabled by using SQL config " + \
+                                
"`spark.sql.execution.pandas.convertToArrowArraySafely`."
+                    raise ValueError(error_msg % (s.dtype, t)) from e

Review comment:
       In `branch-3.0`.
   
   ```
     File 
"/home/jenkins/workspace/spark-branch-3.0-test-sbt-hadoop-2.7-hive-1.2/python/pyspark/sql/pandas/serializers.py",
 line 166
       raise ValueError(error_msg % (s.dtype, t)) from e
                                                 ^
   SyntaxError: invalid syntax
   ```




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

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