You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/16 17:54:47 UTC

[GitHub] [spark] luranhe opened a new pull request #33399: `udf` should return `UserDefinedFunction`

luranhe opened a new pull request #33399:
URL: https://github.com/apache/spark/pull/33399


   The following code should type-check:
   
   ```python3
   import uuid
   
   import pyspark.sql.functions as F
   
   my_udf = F.udf(lambda: str(uuid.uuid4())).asNondeterministic()
   ```
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   The `udf` function should return a more specific type.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Right now, `mypy` will throw spurious errors, such as for the code given above.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   This was not tested. Sorry, I am not very familiar with this repo -- are there any typing tests?


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883620284


   **[Test build #141354 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141354/testReport)** for PR 33399 at commit [`b71fc4b`](https://github.com/apache/spark/commit/b71fc4b88ae466d292357c94af3e7e856413e0a5).


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


[GitHub] [spark] HyukjinKwon commented on a change in pull request #33399: `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r671938267



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       @zero323 do you have any thought on this?




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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886818091


   **[Test build #141642 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141642/testReport)** for PR 33399 at commit [`d16975f`](https://github.com/apache/spark/commit/d16975fcdb6458f94ea5c0aeb86280f4717ba931).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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


[GitHub] [spark] SparkQA removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-884985096


   **[Test build #141503 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141503/testReport)** for PR 33399 at commit [`c9f2858`](https://github.com/apache/spark/commit/c9f285887e3dd3abdfa64270b31684fe3c3e4553).


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


[GitHub] [spark] luranhe commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
luranhe commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r675633352



##########
File path: python/pyspark/sql/_typing.pyi
##########
@@ -54,4 +54,10 @@ class SupportsClose(Protocol):
     def close(self, error: Exception) -> None: ...
 
 class UserDefinedFunctionLike(Protocol):
-    def __call__(self, *_: ColumnOrName) -> Column: ...
+    func: Callable[..., Any]
+    evalType: int
+    deterministic: bool
+    @property
+    def returnType(self) -> pyspark.sql.types.DataType: ...
+    def __call__(self, *cols: ColumnOrName) -> Column: ...

Review comment:
       Oh my bad, that's a good catch! However, if we change this to be `args` then a `UserDefinedFunction` wouldn't type properly as a `UserDefinedFunctionLike`, would it?




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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883656005


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45869/
   


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


[GitHub] [spark] HyukjinKwon commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883279461


   Jenkins, ok to test


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


[GitHub] [spark] HyukjinKwon commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883279461


   Jenkins, ok to test


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883638452


   **[Test build #141354 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141354/testReport)** for PR 33399 at commit [`b71fc4b`](https://github.com/apache/spark/commit/b71fc4b88ae466d292357c94af3e7e856413e0a5).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883297900






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


[GitHub] [spark] HyukjinKwon commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883804824


   I'll leave it to @zero323.


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r676868366



##########
File path: python/pyspark/sql/_typing.pyi
##########
@@ -54,4 +54,10 @@ class SupportsClose(Protocol):
     def close(self, error: Exception) -> None: ...
 
 class UserDefinedFunctionLike(Protocol):
-    def __call__(self, *_: ColumnOrName) -> Column: ...
+    func: Callable[..., Any]
+    evalType: int
+    deterministic: bool
+    @property
+    def returnType(self) -> pyspark.sql.types.DataType: ...
+    def __call__(self, *cols: ColumnOrName) -> Column: ...

Review comment:
       Thanks @luranhe ‒ I'll merge it tomorrow, unless there are any further comments.




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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883701914


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/45869/
   


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


[GitHub] [spark] zero323 commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-887270160


   Merged to master, branch-3.2 and branch-3.1.


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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883653617


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141354/
   


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672996669



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Also, `UserDefinedFunctionWrapper` is just a typing helper without corresponding class, so let's move it into `pyspark.sql._typing.pyi`.  




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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883368552


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/45842/
   


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883297900


   **[Test build #141327 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141327/testReport)** for PR 33399 at commit [`0798c83`](https://github.com/apache/spark/commit/0798c83897b1ad45de8e438d20a8eebf9a219bae).


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


[GitHub] [spark] HyukjinKwon commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672720815



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Yeah, let's do that




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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886797008


   **[Test build #141642 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141642/testReport)** for PR 33399 at commit [`d16975f`](https://github.com/apache/spark/commit/d16975fcdb6458f94ea5c0aeb86280f4717ba931).


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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886884084


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46158/
   


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


[GitHub] [spark] luranhe commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
luranhe commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r674842159



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -17,11 +17,12 @@
 # under the License.
 
 from typing import overload
-from typing import Any, Callable, Dict, List, Optional, Union
+from typing import Any, Callable, Dict, List, Optional, Protocol, Union

Review comment:
       My bad, sorry




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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883701914


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/45869/
   


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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883368552


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/45842/
   


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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-881619579


   Can one of the admins verify this patch?


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


[GitHub] [spark] HyukjinKwon commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672720815



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Yeah, let's do that




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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886842528


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141642/
   


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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-881619579


   Can one of the admins verify this patch?


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883367110


   Kubernetes integration test unable to build dist.
   
   exiting with code: 1
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45842/
   


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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883653617


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141354/
   


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


[GitHub] [spark] HyukjinKwon commented on a change in pull request #33399: `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r671938014



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       It returns a wrapped function. So the previous signature is correct.




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


[GitHub] [spark] SparkQA removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883620284


   **[Test build #141354 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141354/testReport)** for PR 33399 at commit [`b71fc4b`](https://github.com/apache/spark/commit/b71fc4b88ae466d292357c94af3e7e856413e0a5).


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r675420102



##########
File path: python/pyspark/sql/_typing.pyi
##########
@@ -54,4 +54,10 @@ class SupportsClose(Protocol):
     def close(self, error: Exception) -> None: ...
 
 class UserDefinedFunctionLike(Protocol):
-    def __call__(self, *_: ColumnOrName) -> Column: ...
+    func: Callable[..., Any]
+    evalType: int
+    deterministic: bool
+    @property
+    def returnType(self) -> pyspark.sql.types.DataType: ...
+    def __call__(self, *cols: ColumnOrName) -> Column: ...

Review comment:
       To be precise [wrapper uses](https://github.com/apache/spark/blob/2fe12a75206d4dbef6d7678b876c16876136cdd0/python/pyspark/sql/udf.py#L198) `*args` not `*cols`.  I used `_`, because what we advertise to the end user, is different from wrapped signature (we might be able to do better, once we drop support for Python < 3.10, but that's far away from now). If we want to change this, I'd recommend `*args` not `*cols`.
   
   Other than that LGTM. 
   
   




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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886884084


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46158/
   


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672996669



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Also, `UserDefinedFunctionWrapper` is just a typing helper without corresponding class, so let's move it into `pyspark.sql._typing.pyi`.  




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


[GitHub] [spark] HyukjinKwon commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672720815



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Yeah, let's do that




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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-884985096


   **[Test build #141503 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141503/testReport)** for PR 33399 at commit [`c9f2858`](https://github.com/apache/spark/commit/c9f285887e3dd3abdfa64270b31684fe3c3e4553).


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r671987962



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Yeah, this should be addressed, but I am not sure what is the best approach here. We'll definitely need a protocol  ‒ at first glance something like this should be sufficient:
   
   ```python
   class UserDefinedFunctionWrapper(Protocol):
       def __call__(self, *args: Column) -> Column: ...
       def asNonDeterministic(self) -> UserDefinedFunctionWrapper: ...
   ```
   and shouldn't break any existing annotations, but I haven't tested it thoroughly. 
   
   @luranhe Thanks for your proposal. Would you mind creating a [JIRA ticket](https://issues.apache.org/jira/projects/SPARK/issues/) and updating the title accordingly (it should be of form `[SPARK-XXXXX][PYTHON] ...`). Thanks in advance.




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


[GitHub] [spark] SparkQA removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883297900


   **[Test build #141327 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141327/testReport)** for PR 33399 at commit [`0798c83`](https://github.com/apache/spark/commit/0798c83897b1ad45de8e438d20a8eebf9a219bae).


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


[GitHub] [spark] zero323 closed pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 closed pull request #33399:
URL: https://github.com/apache/spark/pull/33399


   


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r675750353



##########
File path: python/pyspark/sql/_typing.pyi
##########
@@ -54,4 +54,10 @@ class SupportsClose(Protocol):
     def close(self, error: Exception) -> None: ...
 
 class UserDefinedFunctionLike(Protocol):
-    def __call__(self, *_: ColumnOrName) -> Column: ...
+    func: Callable[..., Any]
+    evalType: int
+    deterministic: bool
+    @property
+    def returnType(self) -> pyspark.sql.types.DataType: ...
+    def __call__(self, *cols: ColumnOrName) -> Column: ...

Review comment:
       (Specifically, we needed a way to express a fact, that object that we get, is callable and takes variable number of `str` or `Column` arguments and returns a `Column`. This is something that cannot be done with simple `Callable`, but is quite useful for the end user)




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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883316307


   **[Test build #141327 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141327/testReport)** for PR 33399 at commit [`0798c83`](https://github.com/apache/spark/commit/0798c83897b1ad45de8e438d20a8eebf9a219bae).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-885023963


   Kubernetes integration test unable to build dist.
   
   exiting with code: 1
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46020/
   


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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886842528


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141642/
   


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883685027


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45869/
   


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r674715331



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -17,11 +17,12 @@
 # under the License.
 
 from typing import overload
-from typing import Any, Callable, Dict, List, Optional, Union
+from typing import Any, Callable, Dict, List, Optional, Protocol, Union

Review comment:
       Nitpick: We don't need `Protocol` here.




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


[GitHub] [spark] HyukjinKwon commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-887129039


   Test failure here https://github.com/luranhe/spark/runs/3162748315?check_suite_focus=true should be ignorable and unrelated.


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


[GitHub] [spark] luranhe commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
luranhe commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r673280518



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Just took a look, should we be using `UserDefinedFunctionLike` [here](https://github.com/apache/spark/blob/0494dc90af48ce7da0625485a4dc6917a244d580/python/pyspark/sql/_typing.pyi#L56)?




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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-885029560






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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886870774


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46158/
   


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


[GitHub] [spark] luranhe commented on a change in pull request #33399: [SPARK-36211][PYTHON] `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
luranhe commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672383020



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Should we also define `func`, `evalType`, `deterministic`, and `returnType` as is done [here](https://github.com/apache/spark/blob/665817bd4fc07b18cee0f8c6ff759288472514c2/python/pyspark/sql/udf.pyi#L26)?




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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-885012901


   **[Test build #141503 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141503/testReport)** for PR 33399 at commit [`c9f2858`](https://github.com/apache/spark/commit/c9f285887e3dd3abdfa64270b31684fe3c3e4553).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r675681356



##########
File path: python/pyspark/sql/_typing.pyi
##########
@@ -54,4 +54,10 @@ class SupportsClose(Protocol):
     def close(self, error: Exception) -> None: ...
 
 class UserDefinedFunctionLike(Protocol):
-    def __call__(self, *_: ColumnOrName) -> Column: ...
+    func: Callable[..., Any]
+    evalType: int
+    deterministic: bool
+    @property
+    def returnType(self) -> pyspark.sql.types.DataType: ...
+    def __call__(self, *cols: ColumnOrName) -> Column: ...

Review comment:
       If I recall correctly only keyword argument names in `Protocols` are checked (and this can be explicitly disabled)\, but even if it wasn't the case, I don't think our intention was ever to cover `UserDefinedFunction` instances. 




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


[GitHub] [spark] zero323 commented on a change in pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
zero323 commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r673319158



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Yes, nice catch @luranhe! 




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


[GitHub] [spark] SparkQA removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886797008


   **[Test build #141642 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141642/testReport)** for PR 33399 at commit [`d16975f`](https://github.com/apache/spark/commit/d16975fcdb6458f94ea5c0aeb86280f4717ba931).


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


[GitHub] [spark] luranhe commented on a change in pull request #33399: [SPARK-36211][PYTHON] `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
luranhe commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672383020



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Should we also define `func`, `evalType`, `deterministic`, and `returnType` as is done [here](https://github.com/apache/spark/blob/665817bd4fc07b18cee0f8c6ff759288472514c2/python/pyspark/sql/udf.pyi#L26)?




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


[GitHub] [spark] luranhe commented on a change in pull request #33399: [SPARK-36211][PYTHON] `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
luranhe commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r672383020



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       Should we also define `func`, `evalType`, `deterministic`, and `returnType` as is done [here](https://github.com/apache/spark/blob/665817bd4fc07b18cee0f8c6ff759288472514c2/python/pyspark/sql/udf.pyi#L26)?




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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-885029560






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


[GitHub] [spark] HyukjinKwon commented on a change in pull request #33399: `udf` should return `UserDefinedFunction`

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #33399:
URL: https://github.com/apache/spark/pull/33399#discussion_r671938214



##########
File path: python/pyspark/sql/functions.pyi
##########
@@ -359,13 +360,13 @@ def variance(col: ColumnOrName) -> Column: ...
 @overload
 def udf(
     f: Callable[..., Any], returnType: DataTypeOrString = ...
-) -> Callable[..., Column]: ...
+) -> UserDefinedFunction: ...

Review comment:
       `asNondeterministic` etc. is manually set to the specific wrapped function. Hm, we should fix the issue though




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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-881619579






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


[GitHub] [spark] AmplabJenkins commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-883331087


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141327/
   


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


[GitHub] [spark] SparkQA commented on pull request #33399: [SPARK-36211][PYTHON] Correct typing of `udf` return value

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33399:
URL: https://github.com/apache/spark/pull/33399#issuecomment-886834883


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46158/
   


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