Oleksiy Dyagilev created SPARK-41554: ----------------------------------------
Summary: Decimal.changePrecision produces ArrayIndexOutOfBoundsException Key: SPARK-41554 URL: https://issues.apache.org/jira/browse/SPARK-41554 Project: Spark Issue Type: Bug Components: SQL Affects Versions: 3.3.1 Reporter: Oleksiy Dyagilev {{Reducing Decimal scale by more than 18 produces exception.}} {code:java} Decimal(1, 38, 19).changePrecision(38, 0){code} {code:java} java.lang.ArrayIndexOutOfBoundsException: 19 at org.apache.spark.sql.types.Decimal.changePrecision(Decimal.scala:377) at org.apache.spark.sql.types.Decimal.changePrecision(Decimal.scala:328){code} Reproducing with SQL query: {code:java} sql("select cast(cast(cast(cast(id as decimal(38,15)) as decimal(38,30)) as decimal(38,37)) as decimal(38,17)) from range(3)").show{code} The bug exists for {{Decimal}} that is stored using compact long only, it works fine with {{Decimal}} that uses {{scala.math.BigDecimal}} internally. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org