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

   ### What changes were proposed in this pull request?
   
   [SPARK-61233](https://issues.apache.org/jira/browse/SPARK-61233): Add 
offline tests for the uncovered paths of the Python drop-in types module.
   
   This adds nine offline tests to `python/tests/test_dropin_offline.py`, which 
exercise the paths of `pyspark/sql/types.py` that the offline suite did not 
execute:
   
   - The user-defined type paths: a null value, and `fromJson` with a missing 
class or a class that is not a `UserDefinedType`.
   - The numpy dtype mapping of `_from_numpy_type`.
   - The internal values of nulls, empty arrays and maps, and values that need 
no conversion (`toInternal`/`fromInternal`).
   - The struct conversions of each input kind (dict, tuple, list, object, 
`Row`), of a struct with a date, and of a variant.
   - The inference of `_infer_type` and `_infer_schema` for UDT-carrying 
values, spatial values, intervals, maps inferred as structs or from the first 
pair, empty lists, unsupported arrays and sets, and namedtuples.
   - The null handling and merging of `_has_nulltype` and `_merge_type` 
(timestamps, spatial SRIDs, strings, nested structs).
   - The converters of `_need_converter`, `_create_converter` and 
`_create_row_inbound_converter`.
   - The verifiers of `_make_type_verifier`: the bounds of a long, a null type, 
UDT mismatches, struct lengths and kinds, variants, and geometries and 
geographies.
   - The collected-value converters of `_udt_converter` for null structs and 
maps.
   
   The expected results match PySpark 4.3.0 for the cases that PySpark has 
(checked by running the same cases against official `pyspark` 4.3.0). The 
drop-in's own helpers (`_udt_converter`, `_udt_field_converters`) are checked 
against their documented behavior. No behavior changes.
   
   ### Why are the changes needed?
   
   The offline coverage of `pyspark/sql/types.py` was 86% (88 lines and 83 
branches unexecuted). These tests take it to 5 unexecuted lines and 9 
unexecuted branches, which cannot run: the `YearMonthIntervalType` and 
`CalendarIntervalType` branches of `_infer_type` (no Python value maps to 
them), the `if dt is not None` guard of the signed-integer loop at import time 
(every signed size is at most 64 bits), the `sys.version_info` guard at import 
time, the `@overload` stubs of `_merge_type`, two `new_msg` bodies in 
`_merge_type` that the function never calls, and a fallthrough in 
`_create_converter` that `_need_converter` already excludes.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   - The nine new tests in `tests/test_dropin_offline.py`, all passing: 
`test_user_defined_type_null_and_json_errors_as_pyspark`, 
`test_numpy_dtypes_map_to_spark_types_as_pyspark`, 
`test_null_and_empty_internal_values_as_pyspark`, 
`test_struct_internal_values_of_each_input_as_pyspark`, 
`test_infer_type_of_each_kind_of_value_as_pyspark`, 
`test_has_null_type_and_merge_types_as_pyspark`, 
`test_converters_of_values_as_pyspark`, 
`test_verify_values_of_each_type_as_pyspark`, 
`test_udt_converters_of_null_structs_and_maps`. They also pass under pytest 9.2.
   - The same cases give the same results with official PySpark 4.3.0 (the 
outputs of both were compared line by line).
   - The lib tests of both crates (664 passed), the build of all tests, also 
with `wasm-udf`, the offline Python suites (2828 passed, 8 skipped), and the 
live drop-in and Arrow suites (233 passed) and live cases (13 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