Repository navigation
[SPARK-61161][CONNECT][PYTHON] Export the deprecated functions of pyspark.sql.connect.functions, such as countDistinct and bitwiseNOT, as PySpark does - #349
Closed
HyukjinKwon wants to merge 1 commit into
Conversation
…park.sql.connect.functions, such as countDistinct and bitwiseNOT, as PySpark does pyspark.sql.connect.functions star-imported pyspark.sql.functions, whose __all__ does not list countDistinct, sumDistinct, approxCountDistinct, chr, toDegrees, toRadians, shiftLeft, shiftRight, shiftRightUnsigned, bitwiseNOT, random, uuid or py_random. PySpark's package star-imports its builtin module, which has no __all__. The package now star-imports the builtin module too, and the builtin module exposes py_random, as PySpark's does. Co-authored-by: Isaac <no-reply@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
SPARK-61161: Export the deprecated functions of
pyspark.sql.connect.functions, such ascountDistinctandbitwiseNOT, as PySpark does.pyspark/sql/connect/functions/__init__.pystar-importspyspark.sql.connect.functions.builtininstead ofpyspark.sql.functions, as PySpark's package does. The builtin module has no__all__, so its public names are exported.pyspark/sql/connect/functions/builtin.pyexposespy_random, therandommodule imported as in PySpark's builtin module.pyspark.sql.functionsitself is unchanged.The public functions of PySpark's
pyspark.sql.connect.functionsthat were missing arecountDistinct,sumDistinct,approxCountDistinct,chr,toDegrees,toRadians,shiftLeft,shiftRight,shiftRightUnsigned,bitwiseNOT,random,uuidandpy_random. The Connect tests use them through theCFalias. After the change, the public names of the package match PySpark 4.3.0's, apart from the expression classes and modules that PySpark's builtin module imports, which are internal.Why are the changes needed?
PySpark 4.3.0 imports these names from the same package.
Does this PR introduce any user-facing change?
Yes.
pyspark.sql.connect.functionsexposes the 13 functions above (andpy_random), as PySpark does.How was this patch tested?
test_connect_functions_package_exports_the_deprecated_functions_as_pyspark: each of the 12 functions of the package is the one of the builtin module,py_randomis therandommodule, andbitwiseNOTbuilds a column. The same results with official PySpark 4.3.0.wasm-udf, and the offline Python suites (2202 passed, 8 skipped), and the live tests of functions and columns (45 passed) against a local Spark 4.3.0 server; rustfmt passes.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.