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

   ### What changes were proposed in this pull request?
   
   [SPARK-61108](https://issues.apache.org/jira/browse/SPARK-61108): collected 
rows now name the fields of nested structs by the schema, and `collect` raises 
for calendar intervals, as PySpark Connect does.
   
   As PySpark Connect's `ArrowTableToRowsConversion`, which builds rows by the 
schema of the result:
   - The core decodes the Arrow data of a result by the schema that the server 
sends before it (`decode_arrow_batch_of`, `ArrowValueLayout::of` in 
`crates/spark-connect/src/dataframe.rs`).
   - So the fields of nested structs, also in arrays, maps and user-defined 
types, have the names of the schema. These keep the duplicate names that the 
server's Arrow data numbers as `a_0`, `a_1`.
   - This holds for `collect`, `first`, `head`, `take`, `tail` and 
`toLocalIterator`.
   
   As PySpark Connect's `collect`, which checks the Arrow schema of the result 
with `from_arrow_schema`, `collect`, `first`, `head`, `take` and `tail` raise 
`UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION` for a calendar interval: 
"month_day_nano_interval is not supported in conversion to Arrow". Its 
`toLocalIterator` does not check, and neither does the client's.
   
   ### Why are the changes needed?
   
   The client named nested fields by the Arrow data. For example, `SELECT 
named_struct('a', 1, 'a', 2) AS v` collected `Row(v=Row(a_0=1, a_1=2))` instead 
of `Row(v=Row(a=1, a=2))`, and `v.a` raised `ATTRIBUTE_NOT_SUPPORTED`. It also 
collected a calendar interval as a string such as "14 months 25 days 
18367500000000 ns", where PySpark raises.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Collected rows have the field names of PySpark 4.3.0, and collecting a 
calendar interval raises its error.
   
   ### How was this patch tested?
   
   - A new live test checks the names, the values and `asDict` of nested 
structs of duplicate names, also from `toLocalIterator`, and the error of a 
calendar interval. It passes with official PySpark 4.3.0 and fails without this 
change.
   - A new offline test checks the names of rows decoded by the schema of the 
response, against a mock Connect server, and that `collect` raises for a 
calendar interval where `toLocalIterator` does not.
   - A new core test checks the names of nested structs, also in arrays, 
decoded with a schema, and without one or of another shape.
   - On a local server, 156 cases of `collect`, `first`, `head`, `take`, `tail` 
and `toLocalIterator` of a value of each type give the same results as official 
PySpark 4.3.0.
   - Still different: `toLocalIterator` of a calendar interval gives the 
client's string, where PySpark gives PyArrow's `MonthDayNano`. Returning that 
needs a new variant of the core's `Value`.
   - The lib tests of both crates (590 passed), the build of all tests, also 
with `wasm-udf`, the offline Python suites (2056 passed, 12 skipped), and the 
live drop-in and Arrow suites (160 passed) and live cases (10 passed) against a 
local Spark 4.3.0 server. Clippy reports no diagnostics in the changed lines.
   
   ### 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