HyukjinKwon opened a new pull request, #664:
URL: https://github.com/apache/spark-connect-rust/pull/664

   ### What changes were proposed in this pull request?
   
   A follow-up to #611 from its post-merge review. PySpark's `OneVsRest._fit` 
reads the max label first, by `dataset.agg`, and then trains in 
`ThreadPool(processes=min(parallelism, numClasses))`. It never sends 
`parallelism`. The Python client checked `parallelism` first, read it as a 
32-bit int, and refused one that PySpark can't send. Against `pyspark-client` 
4.3.0:
   
   | Case | PySpark | Before |
   |---|---|---|
   | `parallelism=2**31`, `2**32`, `2**40` | fits | `ValueError` (the int 
wrapped below 1) |
   | `parallelism=2**63`, `2**100` | fits | `PySparkValueError` 
`VALUE_NOT_BETWEEN` |
   | `parallelism=None` | `TypeError: '<' not supported between instances of 
'int' and 'NoneType'` | `PySparkValueError` |
   | `parallelism=0` or `None`, no label column | `AnalysisException` 
`UNRESOLVED_COLUMN` | the parallelism error |
   | an empty dataset | `TypeError` of `int(None)` | `ValueError` or 
`PySparkValueError` |
   | `fit(None)` | `AttributeError` of `agg` | `ValueError` of the parallelism |
   
   The Python client now follows PySpark's order:
   - It reads the max label first, with the new `OneVsRest::max_label`.
   - It takes the class count and thread count with Python's own `int()` and 
`min()`, so their errors are those of the running Python.
   - It then fits, with the new `OneVsRest::fit_classes`.
   
   A parallelism beyond 64 bits is kept as the bound of its sign, 
`Kind::ClampedInt`, since `min()` is all PySpark does with it. The Rust API 
keeps its checks before any request, and now reads a 64-bit parallelism without 
wrapping it.
   
   ### Why are the changes needed?
   
   To fit and raise as PySpark does.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. The cases above now behave as in PySpark.
   
   ### How was this patch tested?
   
   - New live tests in `test_remaining_classifiers_e2e.py` cover each case 
above. With the file's other tests, the file passes against a Spark 4.3.0 
Connect server: 48 passed. Its 30 OneVsRest tests pass unchanged on the 
official `pyspark-client` 4.3.0.
   - `test_ml_offline.py`: 340 passed. #611's test, which expected the 
parallelism error before the dataset is read, now checks the `AttributeError` 
of `agg` for any parallelism.
   - Rust:
     - a unit test for the 64-bit parallelism;
     - a live test of `max_label` and of a fit with a parallelism of 2⁴⁰;
     - the classifier live tests: 5 passed.
     - clippy and fmt are clean.
   
   ### 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]

Reply via email to