HyukjinKwon opened a new pull request, #886:
URL: https://github.com/apache/spark-connect-rust/pull/886
### What changes were proposed in this pull request?
A follow-up of SPARK-62078 (#884), which gave the UDF and UDTF registrations
and the streaming classes the docstrings that PySpark Connect copies of
PySpark's classic classes, and which added `scripts/gen_connect_docstrings.py`.
The other modules of PySpark Connect that copy docstrings are catalog, conf,
datasource, group, merge, observation, readwriter and tvf. They make 145 more
assignments: 8 class docstrings and 137 member docstrings.
| Class | Docstrings |
|---|---|
| `Catalog` | 38 |
| `RuntimeConf` | 7 |
| `DataSourceRegistration` | 1 |
| `GroupedData` | 15 |
| `PandasCogroupedOps` | 3 |
| `MergeIntoWriter` and its clauses | 17 |
| `Observation` | 4 |
| `DataFrameReader` | 15 |
| `DataFrameWriter` | 18 |
| `DataFrameWriterV2` | 12 |
| `TableValuedFunction` | 15 |
The drop-in's classes of these modules are native. All 145 of their
docstrings differed from pyspark-client's, compared by their exact text.
Details are in `jira-SPARK-62080-connect-docstrings-rest.txt`. Now:
- **The generator covers these modules too.** `gen_connect_docstrings.py`
generates their docstrings, and each class and member takes its `connect_doc!`,
as those of `streaming.rs` do. The files are `catalog.rs`, `conf.rs`,
`datasource.rs`, `group.rs`, `observation.rs`, `readwriter.rs`, `tvf.rs`, and
the writer and merge classes of `dataframe.rs`.
- In `dataframe.rs`, only the region of `MergeIntoWriter`, its clauses,
`DataFrameWriter` and `DataFrameWriterV2` changes, doc attributes only.
- Their doc comments, which were the docstrings, are now plain comments.
- `lib.rs` declares the macro's module first, as `catalog.rs` and
`conf.rs` come before it.
- **Two docstrings stay CPython's.** The `__init__` of `RuntimeConf` and of
`Observation` is CPython's slot of a native class, which keeps CPython's
docstring; the class cannot set it. The generator leaves these two out, and
`dev/parity/known-differences.md` describes them.
- **The test** of the docstrings that PySpark Connect copies covers all 194
of the modules. It compares them with the classic classes of `pyspark.sql`,
which are Apache Spark's modules as they are.
- **Docs:** `docs/compatibility.md` names the classes whose docstrings are
PySpark's, and the paragraph is wrapped again at 100 columns.
### Why are the changes needed?
So that `help()` of the catalog, the conf, the readers and writers, the
grouped data, the merge writer, the Observation and the table-valued functions
shows PySpark's documentation, as with pyspark-client.
### Does this PR introduce _any_ user-facing change?
Yes. The `__doc__` of 143 of the 145 is PySpark Connect's. For example:
| | pyspark-client and this PR | before |
|---|---|---|
| `Catalog.listTables` | 1343 characters | 84 |
| `RuntimeConf.get` | 1846 characters | 306 |
| `DataFrameWriter.option` | 1193 characters | None |
### How was this patch tested?
- **The extended test**
`test_the_connect_objects_have_the_docstrings_that_pyspark_connect_copies` in
`test_dropin_class_modules_offline.py`, 194 cases. On master 192 fail; the 2
that pass are the two `__init__` slots, which it checks stay CPython's.
- **Probe of both clients:** SHA-256 of the 145 docstrings. 143 are
identical between pyspark-client and this branch, and the 2 `__init__` differ.
All 145 differ on master.
- **Official suites** against the drop-in (`run_official_tests.py --dropin
--only`) of `test_parity_catalog`, `test_parity_conf`, `test_parity_group`,
`test_parity_readwriter`, `test_parity_tvf`, `test_parity_observation`,
`test_parity_python_datasource` and `test_connect_readwriter`: 27, 5, 8, 22,
24, 13, 37 (4 skipped) and 0 (38 skipped) passed, the same on master and on
this branch.
- **The gates**, on master b3767bc7, which has SPARK-62078:
- `cargo fmt --all --check`;
- `cargo +1.100.0 clippy -p apache-spark-connect-core -p
apache-spark-connect -p pyspark-rs --all-targets -- -D warnings`;
- `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps` of the four crates,
also `--features apache-spark-connect/wasm-udf`;
- `cargo test -p pyspark-rs --lib`: 15 passed;
- `gen_connect_docstrings.py --check`, `gen_type_stubs.py --check`,
`gen_fn_dispatch.py --check`;
- ruff 0.14.0, the no-stub audit, the guards and
`test_type_stubs_offline.py` (13 passed, 3 skipped);
- the offline suite of `coverage.yml`: 6758 passed, 77 skipped;
- the coverage step of `coverage.yml`, with its commands and its
`.coveragerc`, before the rebase onto b3767bc7: 6766 passed, 79 skipped, 93.43%
(floor 93.00%);
- `test_dropin_e2e.py -k "catalog or conf or group or readwriter or write
or read or tvf or observ or merge or datasource"` against a Spark 4.3.0 server:
62 passed.
### 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]