zhengruifeng opened a new pull request, #55793:
URL: https://github.com/apache/spark/pull/55793

   ### What changes were proposed in this pull request?
   
   In `PandasUDFInputTypeTests._compare_or_generate_golden`, after loading the 
golden CSV, replace `'object'` with `'str'` in the `Python Type` column for 
rows whose `Spark Type` is `string`, but only when running under Pandas `>= 
3.0`. The golden file on disk is unchanged.
   
   ### Why are the changes needed?
   
   The daily-scheduled `Build / Python-only (master, Python 3.12, Pandas 3)` 
workflow is failing `test_pandas_input_type_coercion_vanilla`:
   
   ```
   line mismatch: expects ['string_values', 'string', "['abc', '', 'hello']", 
"['object', 'object', 'object']", ...] but got [..., "['str', 'str', 'str']", 
...]
   line mismatch: expects ['string_null', 'string', "[None, 'test']", 
"['object', 'object']", ...] but got [..., "['str', 'str']", ...]
   ```
   
   Pandas 3.0 changed the default representation of string columns from numpy 
`object` dtype to the dedicated `str` dtype, so the pandas UDF that records 
`str(series.dtype)` now reports `'str'` for string inputs and the recorded 
`Python Type` column no longer matches the golden. The values themselves are 
unchanged.
   
   See https://github.com/apache/spark/actions/runs/25611987987/job/75184547983 
for the failing run.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Test-only change.
   
   ### How was this patch tested?
   
   Ran the full test module under a Pandas 3 conda env (Python 3.13.12, Pandas 
3.0.2, PyArrow 23.0.1, NumPy 2.4.3):
   
   ```
   $ python/run-tests --testnames 
"pyspark.sql.tests.coercion.test_pandas_udf_input_type"
   Tests passed in 17 seconds
   ```
   
   The Pandas `< 3.0` branch is a no-op, so existing behaviour is preserved.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (claude-opus-4-7)


-- 
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