anshulbaliga7 commented on PR #60714: URL: https://github.com/apache/spark/pull/60714#issuecomment-7062500715
Thank you for the detailed review @dongjoon-hyun. Have addressed all in e80bc8c4fef: - Shared helper: `_validate_random_split_weights` in `python/pyspark/sql/dataframe.py`, next to the `approxQuantile` helpers, is now used by both classic and Spark Connect. It reads the weights once, so a one-shot iterable is no longer exhausted, and the second pass, `double_weights` and the cast are gone. The negative and sum checks run on the given values, so a negative int is still reported as `-1`. - Sum: classic now checks `sum(weights) > 0` on the Python side and raises `VALUE_NOT_POSITIVE` with `arg_name="sum(weights)"`, as Spark Connect does. - Decimal: I went with rejecting it on both sides with `NOT_EXPECTED_TYPE`, as `_validate_approx_quantile_probabilities` and `_validate_approx_quantile_relative_error` do. It also rejects `bool` for the same reason. One behavior change to flag: Spark Connect used to count `True` as `1`. I used `numbers.Real` rather than `(float, int)` so that NumPy scalars, which Spark Connect accepts today, keep working on both sides. - Huge ints: when `float()` overflows, the helper divides the weights by their exact sum first, as Spark Connect does, so `[10**400, 10**400]` splits like `[1.0, 1.0]` on both sides. - `_to_list`: classic now calls `PythonUtils.toList` directly. - Tests: added `[2**40, 2**41]` (the `java.lang.Long` path), `[1, 2.0]` and `[10**400, 10**400]`, all compared with the float weights through the collected rows only, and a second test for the errors (negative, zero sum, `Decimal`, `bool`). Both run in the Spark Connect parity suite too. - Docs: the `randomSplit` docstring now says "list of floats or ints as weights". Can you PTAL again? Thanks! -- 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]
