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

   ### What changes were proposed in this pull request?
   
   The type of an inferred pandas object column that mixes Decimal values with 
other values now comes from Arrow, as in PySpark, whose conversion of pandas 
leaves such a column to Arrow (`arrow_decimal_column` in 
`python/pyspark/sql/_pandas_input.py`, called from `create_from_pandas`): Arrow 
types the column, takes ints as Decimals, and raises for the others, which 
become PySpark's `PySparkTypeError` or `PySparkValueError` ("Exception thrown 
when converting pandas.Series (object) with name 'd' to Arrow Array (None)."). 
Columns of Decimals alone keep their inference from the text of each value 
(#133).
   
   ### Why are the changes needed?
   
   [SPARK-61071](https://issues.apache.org/jira/browse/SPARK-61071): such a 
column raised `AttributeError: 'int' object has no attribute 'as_tuple'`, or 
typed a column whose first value is an int as bigint and then failed. Against a 
local Spark 4.3.0 server, these now give the same results as PySpark 4.3.0:
   
   | Column | Current master | This change and PySpark 4.3.0 |
   | --- | --- | --- |
   | `[Decimal("1.5"), 2]` | `AttributeError` | `decimal(2,1)`, `[1.5, 2.0]` |
   | `[2, Decimal("1.5")]` | `PySparkRuntimeError: Type mismatch in row data` | 
`decimal(2,1)`, `[2.0, 1.5]` |
   | `[Decimal("1.5"), 2.5]` or `"x"` | `AttributeError` | `PySparkTypeError` |
   | `[Decimal("1.5"), True]`, `[Decimal("-0.5"), -3, None]`, 
`[Decimal("1.25"), 10**20]` | `AttributeError` | `PySparkValueError` |
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, these columns convert, or fail, as in PySpark.
   
   ### How was this patch tested?
   
   - A new offline test in `python/tests/test_dropin_offline.py` for each case 
above, against the mock server that records the uploaded Arrow IPC (types and 
cells), and the Decimal tests of the offline suite.
   
   ### 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