You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Junqing Li (Jira)" <ji...@apache.org> on 2025/04/29 03:26:00 UTC

[jira] [Created] (SPARK-51941) CatalystTypeConverters.convertToCatalyst failed to convert BigDecimal between -1.0 and 1.0

Junqing Li created SPARK-51941:
----------------------------------

             Summary: CatalystTypeConverters.convertToCatalyst failed to convert BigDecimal between -1.0 and 1.0
                 Key: SPARK-51941
                 URL: https://issues.apache.org/jira/browse/SPARK-51941
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.5.5, 4.0.0, 4.1.0
            Reporter: Junqing Li


In SPARK-20211, we addressed a fix with BigDecimal type conversion exceptions. However, the CatalystTypeConverters.convertToCatalyst method was not updated accordingly, causing users to still encounter exceptions when attempting to convert BigDecimal types. Below is a reproducible example case for this problem.
{code:java}
CatalystTypeConverters.convertToCatalyst(BigDecimal("0.01")) {code}
{code:java}
Decimal scale (2) cannot be greater than precision (1).
org.apache.spark.sql.AnalysisException: Decimal scale (2) cannot be greater than precision (1).
    at org.apache.spark.sql.errors.DataTypeErrors$.decimalCannotGreaterThanPrecisionError(DataTypeErrors.scala:122)
    at org.apache.spark.sql.types.DecimalType.<init>(DecimalType.scala:46)
    at org.apache.spark.sql.catalyst.CatalystTypeConverters$.convertToCatalyst(CatalystTypeConverters.scala:578)
    at org.apache.spark.sql.catalyst.CatalystTypeConvertersSuite.$anonfun$new$18(CatalystTypeConvertersSuite.scala:159) {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org