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

   ### What changes were proposed in this pull request?
   
   Two tests of `python/tests/test_arrow_handoff.py`, 
`test_float64_class_conversion_hooks_keep_row_fallback[True-*]` and 
`test_string_class_conversion_hooks_keep_row_fallback[True-*]`, remove 
`pyspark.sql._pandas_input` from `sys.modules` with `monkeypatch.delitem`, so 
that the client imports the module again, as on its first use. That import 
binds the new module object to the package's attribute 
`pyspark.sql._pandas_input` too. At the end of the test, monkeypatch restores 
the entry of `sys.modules`, but nothing restores the attribute.
   
   So in a later test of the same process:
   - `from pyspark.sql import _pandas_input` gets the new module, through the 
attribute;
   - the client's `import("pyspark.sql._pandas_input")` gets the old one, 
through `sys.modules`.
   
   A test that monkeypatches a function of the helper then patches a module 
that the client does not call. 12 tests of `test_dropin_offline.py` fail that 
way when they run after these tests in one process: the `customized_pandas_*` 
tests, `tuple_rows_remain_named_structs_in_native_input[*-pandas]` and 
`decimal_explicit_pandas_schema_uses_arrow_conversion`.
   
   A new helper, `_forget_pandas_input`, removes both the entry and the 
attribute through monkeypatch, so both are restored.
   
   ### Why are the changes needed?
   
   The failure depends on the order of the test files. The coverage job of CI 
lists `test_dropin_offline.py` before `test_arrow_handoff.py`, so it passes 
there. Any run that collects `test_arrow_handoff.py` first, for example the 
files in alphabetical order, fails those 12 tests. Bisecting the tests of 
`test_arrow_handoff.py` found 
`test_float64_class_conversion_hooks_keep_row_fallback[True-astype]` alone 
enough.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No, tests only.
   
   ### How was this patch tested?
   
   - Before: `pytest 
tests/test_arrow_handoff.py::test_float64_class_conversion_hooks_keep_row_fallback
 
tests/test_dropin_offline.py::test_customized_pandas_row_discovery_walks_only_object_columns`
 fails the second test.
   - After: running both class-conversion tests before the 12 tests passes all 
104 selected tests.
   - `ruff check` and `ruff format --check` (ruff 0.14.0).
   
   ### 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