This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new ce44afc413a [SPARK-43057][FOLLOWUP][CONNECT][PYTHON] Add & refine 
errors
ce44afc413a is described below

commit ce44afc413abf494778ec6553c355937e51a44fb
Author: itholic <[email protected]>
AuthorDate: Wed May 3 19:42:27 2023 +0900

    [SPARK-43057][FOLLOWUP][CONNECT][PYTHON] Add & refine errors
    
    ### What changes were proposed in this pull request?
    
    This is follow-up for https://github.com/apache/spark/pull/40694 to redeem 
some errors.
    
    ### Why are the changes needed?
    
    To make errors clear
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    The existing CI should pass
    
    Closes #41032 from itholic/connect_followup.
    
    Authored-by: itholic <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 python/pyspark/errors/error_classes.py |  5 +++++
 python/pyspark/sql/connect/column.py   | 10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/python/pyspark/errors/error_classes.py 
b/python/pyspark/errors/error_classes.py
index 15a8bd5c3b3..2f559b6a538 100644
--- a/python/pyspark/errors/error_classes.py
+++ b/python/pyspark/errors/error_classes.py
@@ -34,6 +34,11 @@ ERROR_CLASSES_JSON = """
       "Attribute `<attr_name>` in provided object `<obj_name>` is not 
callable."
     ]
   },
+  "ATTRIBUTE_NOT_SUPPORTED" : {
+    "message" : [
+      "Attribute `<attr_name>` is not supported."
+    ]
+  },
   "BROADCAST_VARIABLE_NOT_LOADED": {
     "message": [
       "Broadcast variable `<variable>` not loaded."
diff --git a/python/pyspark/sql/connect/column.py 
b/python/pyspark/sql/connect/column.py
index 7b60adb1629..2fdc3aabd4a 100644
--- a/python/pyspark/sql/connect/column.py
+++ b/python/pyspark/sql/connect/column.py
@@ -138,9 +138,9 @@ class Column:
 
     # container operators
     def __contains__(self, item: Any) -> None:
-        raise ValueError(
-            "Cannot apply 'in' operator against a column: please use 
'contains' "
-            "in a string column or 'array_contains' function for an array 
column."
+        raise PySparkValueError(
+            error_class="CANNOT_APPLY_IN_FOR_COLUMN",
+            message_parameters={},
         )
 
     # bitwise operators
@@ -438,7 +438,9 @@ class Column:
                 error_class="JVM_ATTRIBUTE_NOT_SUPPORTED", 
message_parameters={"attr_name": "_jc"}
             )
         if item.startswith("__"):
-            raise AttributeError(item)
+            raise PySparkAttributeError(
+                error_class="ATTRIBUTE_NOT_SUPPORTED", 
message_parameters={"attr_name": item}
+            )
         return self[item]
 
     def __getitem__(self, k: Any) -> "Column":


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to