[SPARK-56373][PYSPARK] Add docstring annotations to classify PySpark APIs for Spark Connect compatibility#55234
Open
garlandz-db wants to merge 3 commits intoapache:masterfrom
Open
Conversation
…APIs for Spark Connect compatibility Adds three RST directives to PySpark modules, classes, and methods to indicate Spark Connect compatibility status: - `.. classic:: true` -- API is only available in Classic Spark (not Spark Connect) - `.. connect:: true` -- API is available in Spark Connect - `.. connect_migration:: <message>` -- migration guidance for users transitioning to Spark Connect Annotations are resolved by inheriting from the nearest annotated ancestor; a child annotation overrides the parent's. No functional code changes -- docstrings only. The annotation spec is documented in `python/pyspark/__init__.py`.
31cd9c7 to
242e1ef
Compare
- Remove annotation spec documentation from pyspark/__init__.py module
docstring to prevent it from being parsed as a real directive by tooling
- Fix setLogLevel migration: spark.log.level() does not exist; use
spark.conf.set("spark.log.level", level) instead
- Fix setJobGroup migration: wrong config key and mechanism; use the
tag API (spark.addTag/interruptTag) instead
- Fix defaultParallelism migration: remove fabricated "200" default
- Improve setLocalProperty migration: note that spark.conf.set is
session-global, not thread-local
- Improve readwriter.json migration: handle JSON string input correctly
- Improve udf.registerJavaFunction: cover non-notebook use cases
- Improve mllib migration: list supported/unsupported modules explicitly
…rk/__init__.py The documentation section explaining the directive syntax was removed in the previous commit to fix a parser false-match issue. The fix has been moved to the tooling layer (strip RST inline code spans before regex matching), so the documentation can be restored here.
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?
Adds three RST docstring directives to PySpark modules, classes, and methods to annotate their Spark Connect compatibility:
.. classic:: true— the API is only available in Classic Spark (not Spark Connect).. connect:: true— the API is available in Spark Connect.. connect_migration:: <message>— migration guidance for users transitioning from Classic Spark to Spark ConnectThe annotation spec is documented in
python/pyspark/__init__.py. Annotations are resolved by inheriting from the nearest annotated ancestor; a child annotation overrides the parent's.Annotated modules/classes in this PR:
pyspark.coreand its submodules (RDD, SparkContext, etc.) — Classic only, with per-method migration guidancepyspark.mllib— Classic only, migrate topyspark.ml.connectpyspark.ml.clustering(LDA family) — Classic onlypyspark.ml.deepspeed,pyspark.ml.torch— Classic onlypyspark.ml.wrapper— Classic onlypyspark.ml.connect— Connectpyspark.sql.classic,pyspark.sql.connect— Classic / Connect respectivelypyspark.sql.context— Classic only (use SparkSession instead)pyspark.sql.dataframe.DataFrame.rdd— migration guidancepyspark.sql.readwriter.DataFrameReader.json— migration guidance for RDD argpyspark.sql.udf.UDFRegistration.registerJavaFunction— migration guidancepyspark.sql.metrics,pyspark.errors.exceptions.connect— ConnectWhy are the changes needed?
These annotations enable tooling (IDEs, documentation generators, linters) to surface accurate Spark Connect compatibility information to users, helping them understand which APIs are available in Spark Connect and how to migrate.
Does this PR introduce any user-facing change?
No. Docstring-only changes; no functional code modifications.
How was this patch tested?
No tests added — docstring-only changes. Existing test suites continue to pass.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude (Anthropic), claude-sonnet-4-6