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

   ### What changes were proposed in this pull request?
   
   [SPARK-61026](https://issues.apache.org/jira/browse/SPARK-61026): `sample`, 
`sort`, `groupBy`, `drop` and `selectExpr` now take their arguments as 
PySpark's do.
   
   - `df.sample(withReplacement, fraction, seed)` takes a fraction and a seed 
positionally, as in `sample(0.5, 42)`. It also takes a bool and a float, or a 
fraction alone, and raises `NOT_EXPECTED_TYPE` for other arguments.
   - `df.sort`, `df.orderBy` and `df.sortWithinPartitions` take the 1-based 
ordinals of columns, descending for a negative one. `df.sort(2)` sorts by the 
second column, and `df.sort(-2)` by it descending. They raise `CANNOT_BE_EMPTY` 
without columns, `ZERO_INDEX` for 0, and `NOT_EXPECTED_TYPE` for another type. 
They apply `ascending` as PySpark does.
   - `df.groupBy`, `df.rollup`, `df.cube` and `df.groupingSets` take the 
1-based ordinals of columns, and raise `INDEX_NOT_POSITIVE` for one that is not 
positive.
   - `df.drop` takes Columns, which it sends as expressions, as well as column 
names. It raises `NOT_EXPECTED_TYPE` for another type.
   - `df.selectExpr` takes a list of expressions.
   
   In the Rust API, `DataFrame::drop_columns` drops Columns and column names.
   
   ### Why are the changes needed?
   
   - The 42 of `df.sample(0.5, 42)` was taken as the fraction, which failed on 
the server.
   - The ordinals of `sort` and `groupBy` raised `TypeError`s.
   - The Columns of `drop` raised `TypeError`s.
   - The list of `selectExpr` raised a `TypeError`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. These methods take the arguments of PySpark 4.3.0.
   
   ### How was this patch tested?
   
   - A new live test sorts and groups by ordinals, drops Columns, selects a 
list of expressions, and samples by a positional fraction and seed. It passes 
with official PySpark 4.3.0, and fails without this change.
   - A new offline test checks the relations sent to a mock Connect server for 
these calls, and their errors. It fails without this change.
   
   ### 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