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

   ### What changes were proposed in this pull request?
   
   [SPARK-61335](https://issues.apache.org/jira/browse/SPARK-61335): the fill 
values of `DataFrame::fillna_value` and `fillna_map` of the Rust API are sent 
as PySpark sends them, and the others are rejected.
   
   - In `crates/spark-connect/src/plan.rs`, `value_to_proto_literal` follows 
PySpark's `NAFill._convert_value`, which sends the only types the server's fill 
takes:
     - a bool as a boolean;
     - an integer (`Byte`, `Short`, `Integer`, `Long`) as a long;
     - a float as a double;
     - a string as a string.
   - A value that only a directly built plan can hold gets its own literal 
type, or an empty literal for nested values, so that the server rejects it.
   - In `crates/spark-connect/src/dataframe.rs`, `fillna_value` and 
`fillna_map` check their values as PySpark's `fillna` does:
     - any other value is `NOT_EXPECTED_TYPE`, with PySpark's `arg_name` and 
`expected_type`;
     - an empty map is `CANNOT_BE_EMPTY`;
     - so they return a `Result`, as `dropna` does.
   - `fillna`, `fillna_double`, `fillna_string` and `fillna_bool` are 
unchanged. The drop-in's `fillna`, which checks its values in Python first, 
maps the `Result`.
   - `docs/compatibility.md` notes the change in the Rust migration section.
   
   ### Why are the changes needed?
   
   A value of a type that PySpark's `fillna` does not take was sent as the 
string of its Debug text, so it silently filled string columns:
   - `Value::Null` filled them with `"Null"`, `Value::Binary` with `"Binary([1, 
2])"`, and `List`, `Map`, `Struct` and `Time` likewise.
   - `Value::Integer(5)` and `Value::Float(1.5)` were sent as an int and a 
float. The server's fill rejects those ("Unsupported value type 
java.lang.Integer (5)."), though PySpark's `fillna(5)` and `fillna(1.5)` work.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, in the Rust API:
   - `fillna_value` and `fillna_map` return a `Result`, and reject the values 
PySpark rejects.
   - An integer or a float fill now works.
   
   ### How was this patch tested?
   
   - Unit (`plan_construction_tests`): 
`fill_values_are_those_of_pyspark_and_sent_as_its_literals`.
     - The eight accepted value types are sent as PySpark's literals, by both 
methods.
     - `Null`, `Binary`, `List` and `Date` are `NOT_EXPECTED_TYPE` with 
PySpark's parameters; an empty map is `CANNOT_BE_EMPTY`.
   - Live (`crates/spark-connect/tests/e2e_ops_breadth.rs`): 
`fill_values_are_sent_as_pyspark_sends_them`. An `Integer` and a `Float` fill 
their columns; the server rejected the integer before.
   - Checks:
     - the lib tests of both crates (719 passed);
     - the build of all tests (also `wasm-udf`, `datafusion,polars`) without 
warnings;
     - `cargo fmt --all --check`, and clippy with no diagnostics on the changed 
lines;
     - the offline Python suites (2980 passed, 8 skipped);
     - the live drop-in, Arrow and ML suites against a local Spark 4.3.0 server 
(254 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]

Reply via email to