L. C. Hsieh created SPARK-61423:
-----------------------------------
Summary: Reject an out-of-range decimal precision or scale when
converting to Arrow instead of wrapping it, in Spark Connect Rust
Key: SPARK-61423
URL: https://issues.apache.org/jira/browse/SPARK-61423
Project: Spark
Issue Type: Bug
Components: Connect
Affects Versions: connect-rust-4.3.0
Reporter: L. C. Hsieh
{{DataType::Decimal}} holds {{i32}} precision and scale and, as PySpark's
{{DecimalType}}, is not validated when it is built or parsed. The two places in
{{crates/spark-connect/src/session.rs}} that turn it into an Arrow
{{Decimal128}} ({{datatype_to_arrow}} and the decimal branch of
{{values_to_arrow}}) narrow the fields with {{as u8}} / {{as i8}}.
So for a schema, or for a column with no non-null value, an out-of-range type
wraps silently instead of raising: {{decimal(257,0)}} becomes the valid
{{Decimal128(1, 0)}}, {{decimal(38,256)}} gets a scale of 0, and
{{decimal(300,0)}} becomes a precision of 44 and fails later with a message
about 44.
PySpark does not validate {{DecimalType}} in the constructor, in a JSON schema
or in the proto conversion (the server rejects the type on analysis), but its
Arrow conversion ({{pa.decimal128(dt.precision, dt.scale)}}) does raise for a
precision outside 1 to 38.
Use checked conversions and Arrow's own Decimal128 limits at the Arrow boundary
and return an error naming the type. Parsing stays unvalidated, as in PySpark.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]