HyukjinKwon opened a new pull request, #416: URL: https://github.com/apache/spark-connect-rust/pull/416
### What changes were proposed in this pull request? [SPARK-61235](https://issues.apache.org/jira/browse/SPARK-61235): Add the `pyspark.sql.connect.resource.profile` module and the `DistributedSequenceID` and `UnresolvedNamedLambdaVariable` expressions of `pyspark.sql.connect.expressions`, as PySpark 4.3.0 has them. - `pyspark/sql/connect/resource/profile.py` re-exports `ResourceProfile` from `pyspark.resource`, as the Connect package already does for the other resource classes. The profile id is the server's already: `ResourceProfile.id` registers the profile through `SparkSession.buildResourceProfile` and caches the server's id, as PySpark's Connect path does. - `pyspark/sql/connect/expressions.py` gets `DistributedSequenceID`, whose `to_plan` is an unresolved function `distributed_sequence_id` with no arguments, and `UnresolvedNamedLambdaVariable`, with the class counter `_nextVarNameId`, `fresh_var_name`, and a `to_plan` of its name parts. Both give the same proto and `repr` as PySpark 4.3.0. - `pyspark/sql/functions.py` names the lambda variables with `UnresolvedNamedLambdaVariable.fresh_var_name`, so resetting its counter changes the names of the lambdas of the connect functions, as in PySpark. ### Why are the changes needed? `from pyspark.sql.connect.resource.profile import ResourceProfile` raised `ModuleNotFoundError`. `from pyspark.sql.connect.expressions import DistributedSequenceID` raised `ImportError`, so the official `pyspark/sql/tests/connect/test_connect_column.py` failed at collection. Official PySpark 4.3.0 imports both. ### Does this PR introduce _any_ user-facing change? Yes. The two imports above work, and the expressions are available under `pyspark.sql.connect.expressions`. ### How was this patch tested? - `test_connect_resource_profile_module_offline` checks that the module's `ResourceProfile` is the `pyspark.resource` class. It fails without the change (`ModuleNotFoundError`). - `test_connect_expressions_distributed_sequence_id_and_lambda_names_offline` checks the repr and proto of `DistributedSequenceID` and `UnresolvedNamedLambdaVariable`, and the lambda names after a counter reset. It fails without the change (`ImportError`). The same cases give the same results with official PySpark 4.3.0 (`DistributedSequenceID()`, `distributed_sequence_id`, `x, y`, `Column<'array_sort(data, LambdaFunction(-(length(x_0), length(y_1)), x_0, y_1))'>`, `z_2`). - The official `test_connect_column.py` now imports (it is skipped by the class gate `ReusedMixedTestCase`, as on the reference). The official `test_connect_resources.py` and `test_parity_resources.py` pass. - The live tests of the resource and higher-order function areas (`-k "resource or profile or lambda or transform or higher or array_sort"`) pass. - The lib tests of both crates (664 passed), the build of all tests, also with `wasm-udf`, the offline Python suites (2821 passed, 8 skipped), and the live drop-in and Arrow suites (233 passed) and live cases (13 passed) against a local Spark 4.3.0 server. Clippy reports no diagnostics in the changed lines. ### 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. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
