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

   ### What changes were proposed in this pull request?
   
   [SPARK-61156](https://issues.apache.org/jira/browse/SPARK-61156): Raise 
`UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION` for year-month and calendar 
interval columns of `createDataFrame` on the client, as PySpark does.
   
   PySpark's local-rows conversion has no converter for `YearMonthIntervalType` 
and `CalendarIntervalType`, so it passes their values through to 
`to_arrow_schema`, which raises a `PySparkTypeError` with 
`UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION` and the type's `str`, for example 
`YearMonthIntervalType(0, 1)` or `CalendarIntervalType()`. The Python client 
already did this for char and varchar types. This change does the same for the 
two interval types:
   
   - `convert` passes a value of these types through, as it does for char and 
varchar, so the schema check runs for None values and for other values alike.
   - `unsupported_arrow_type` also matches these types, so the check raises the 
PySpark error before the server core sees the schema, for top-level, nested in 
struct, array and map, and atomic schemas.
   
   ### Why are the changes needed?
   
   With a year-month interval column, `spark.createDataFrame([(1,)], "a 
interval year to month")` raised `TypeError: unsupported value type for 
createDataFrame: int`. With `[(None,)]` it raised `PySparkRuntimeError: 
Unsupported type for Arrow createDataFrame conversion: YearMonthInterval { 
start_field: 0, end_field: 1 }`, which is Rust Debug text. A calendar interval 
column gave the same two errors with `CalendarInterval`. PySpark raises 
`PySparkTypeError` `UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION` with 
`YearMonthIntervalType(0, 1) is not supported in conversion to Arrow.` for both 
cases.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `createDataFrame` of local rows with a year-month or calendar interval 
column now raises `PySparkTypeError` 
`UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION`, with the same message as PySpark, 
instead of a `TypeError` or a `PySparkRuntimeError` with Rust text.
   
   ### How was this patch tested?
   
   - `test_year_month_and_calendar_intervals_raise_as_pyspark_for_local_rows` 
(offline, mock server): values and None of top-level, struct, nested calendar, 
array and map year-month and calendar columns, and atomic year-month schemas, 
check the error class, the condition and the `data_type` parameter. Each case 
gives the same result with official PySpark 4.3.0.
   - The lib tests of both crates (590 passed), the build of all tests, also 
with `wasm-udf`, and the offline Python suites (2202 passed, 8 skipped), and 
the live tests of intervals, char types and createDataFrame (49 passed) against 
a local Spark 4.3.0 server; rustfmt passes, and 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