Uh oh!
There was an error while loading. Please reload this page.
[SPARK-47909][PYTHON][CONNECT] Parent DataFrame class for Spark Connect and Spark Classic - #46129
[SPARK-47909][PYTHON][CONNECT] Parent DataFrame class for Spark Connect and Spark Classic#46129HyukjinKwon wants to merge 1 commit into
Conversation
HyukjinKwon
commented
Apr 19, 2024
There was a problem hiding this comment.
we can move such complex preprocessing to the superclasses later
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
HyukjinKwon
commented
Apr 19, 2024
Will fix up the tests soon. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
I guess we can leave it as-is? And the following changes?
There was a problem hiding this comment.
this was the way MyPy least complained IIRC. Let me take a look again ..
There was a problem hiding this comment.
Seems like the arguments cannot be more specific type, and return types can't be wider types (https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides). So it complains about the argument.
Let me just keep them all as parent dataframe for simplicity because those types aren't user-facing anyway.
There was a problem hiding this comment.
Here is one example of the error:
python/pyspark/sql/classic/dataframe.py:276: error: Argument 1 of "exceptAll" is incompatible with supertype "DataFrame"; supertype defines the argument type as "DataFrame" [override]
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
I'm wondering if we need @overload definitions in the subclasses?
There was a problem hiding this comment.
I initially added, and removed it back because MyPy complains too much. I will take another look.
There was a problem hiding this comment.
Seems like by right we should redefine the overloads here (python/mypy#5146, python/mypy#10699). However, we're using pyspark.sql.DataFrame type hints even within our codebase .. so I think it's better to don't have them defined here for now.
Should be ready for a look. All tests passed. I squashed/rebased the commits. |
There was a problem hiding this comment.
This might be a breaking change if somebody inherits pyspark.sql.DataFrame before, and it has it's own __init__. However, __init__ is not really an API, and users shouldn't really customize/use/invoke them directly.
HyukjinKwon
commented
Apr 22, 2024
Merged to master. I will followup if there are more comments to address. |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Can we have a different name than classic?
dongjoon-hyun
commented
Apr 22, 2024
|
…c` references ### What changes were proposed in this pull request? This PR is a followup of #46129 that moves `pyspark.classic` references to the actual test methods so they are not references during `pyspark-connect` only test (that does not have `pyspark.classic` package). ### Why are the changes needed? To recover the CI: https://github.com/apache/spark/actions/runs/8789489804/job/24119356874 ### Does this PR introduce _any_ user-facing change? No, test-only. ### How was this patch tested? Manually ### Was this patch authored or co-authored using generative AI tooling? No. Closes#46171 from HyukjinKwon/SPARK-47909-followup. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
… Classic ### What changes were proposed in this pull request? Same as #46129 but for `Column` class. ### Why are the changes needed? Same as #46129 ### Does this PR introduce _any_ user-facing change? Same as #46129 ### How was this patch tested? Manually tested, and CI should verify them. ### Was this patch authored or co-authored using generative AI tooling? No. Closes#46155 from HyukjinKwon/SPARK-47933. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
…and Spark Classic ### What changes were proposed in this pull request? Parent Window class for Spark Connect and Spark Classic ### Why are the changes needed? Same as #46129 ### Does this PR introduce _any_ user-facing change? Same as #46129 ### How was this patch tested? CI ### Was this patch authored or co-authored using generative AI tooling? NO Closes#46841 from zhengruifeng/py_parent_window. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
What changes were proposed in this pull request?
This PR proposes to have a parent
pyspark.sql.DataFrameclass whichpyspark.sql.connect.dataframe.DataFrameandpyspark.sql.classic.dataframe.DataFrameinherit.Note that for backward compatibility concern,
pyspark.sql.DataFrame(...)will return still a Spark Classic DataFrame.Before
pyspark.sql.DataFrame(Spark Claasic)pyspark.sql.connect.dataframe.DataFrame(Spark Connect)Users can only see the type hints from
pyspark.sql.DataFrame.After
pyspark.sql.DataFrame(Common)pyspark.sql.classic.dataframe.DataFrame(Spark Classic)pyspark.sql.connect.dataframe.DataFrame(Spark Connect)Users can only see the type hints from
pyspark.sql.DataFrame.Why are the changes needed?
This fixes two issues in the current structure at Spark Connect:
Support usage of regular methods as class methods, e.g.,
Before
After
Supports
isinstancecallBefore
After
Does this PR introduce any user-facing change?
Yes, as described above.
How was this patch tested?
Manually tested, and CI should verify them.
Was this patch authored or co-authored using generative AI tooling?
No.