[
https://issues.apache.org/jira/browse/SPARK-60312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated SPARK-60312:
-----------------------------------
Labels: pull-request-available (was: )
> VariantVal decoding rounds decimals with more than 28 digits under the
> default Python decimal context
> -----------------------------------------------------------------------------------------------------
>
> Key: SPARK-60312
> URL: https://issues.apache.org/jira/browse/SPARK-60312
> Project: Spark
> Issue Type: Bug
> Components: PySpark
> Affects Versions: 4.0.0
> Reporter: Arthur
> Priority: Major
> Labels: pull-request-available
>
> VariantUtils._get_decimal in python/pyspark/sql/variant_utils.py rebuilds a
> variant decimal by multiplying the unscaled value with a power of ten using
> decimal context arithmetic. Under the default Python context (precision 28) a
> stored DECIMAL16 value with 38 significant digits loses digits in
> VariantVal.toPython() and toJson(). With the Inexact trap enabled, decoding
> raises instead.
> Reproduction (PySpark 4.0.0 and master):
> {code:python}
> from pyspark.sql.types import VariantVal
> value = VariantVal.parseJson("0.12345678901234567890123456789012345678")
> print(value.toPython())
> {code}
> Actual: 0.1234567890123456789012345679
> Expected: 0.12345678901234567890123456789012345678
> Fix: https://github.com/apache/spark/pull/59201 rebuilds the value from the
> coefficient digits and the stored scale, without context arithmetic, and adds
> a regression test for DECIMAL4, DECIMAL8 and DECIMAL16 under precisions 1, 28
> and 38.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]