You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "allisonwang-db (via GitHub)" <gi...@apache.org> on 2023/07/14 22:40:26 UTC

[GitHub] [spark] allisonwang-db commented on a diff in pull request #41948: [SPARK-44380][SQL][PYTHON] Support for Python UDTF to analyze in Python

allisonwang-db commented on code in PR #41948:
URL: https://github.com/apache/spark/pull/41948#discussion_r1264218509


##########
python/pyspark/errors/error_classes.py:
##########
@@ -277,6 +277,11 @@
       "The UDTF '<name>' is invalid. It does not implement the required 'eval' method. Please implement the 'eval' method in '<name>' and try again."
     ]
   },
+  "INVALID_UDTF_RETURN_TYPE" : {

Review Comment:
   I have the same error class defined here: https://github.com/apache/spark/pull/41989/files#diff-2823e146fc0e6bddff3505b5bee6e2b855782d9f71e900e6f9099fc97d1fffa6R280. I will change the error class name in my PR.



##########
python/pyspark/sql/udtf.py:
##########
@@ -103,6 +104,14 @@ class VectorizedUDTF:
         def __init__(self) -> None:
             self.func = cls()
 
+        if hasattr(cls, "analyze") and isinstance(
+            inspect.getattr_static(cls, "analyze"), staticmethod
+        ):
+
+            @staticmethod

Review Comment:
   Why do we make `analyze` a `staticmethod`?
   For example, we could have a UDTF defined in this way:
   ```
   class MyUDTF:
       def __init__(self):
           self.some_boolean_value = ...
       
       def analyze(self, a, b):
           if self.some_boolean_value:
               return StructType(..)
           ...
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org