Description
The multiplication of two BigDecimal numbers sometimes returns null. Here is a minimal reproduction:
object Main extends App { import org.apache.spark.{SparkConf, SparkContext} import org.apache.spark.sql.SparkSession import spark.implicits._ val conf = new SparkConf().setMaster("local[*]").setAppName("REPL").set("spark.ui.enabled", "false") val spark = SparkSession.builder().config(conf).appName("REPL").getOrCreate() implicit val sqlContext = spark.sqlContext case class X2(a: BigDecimal, b: BigDecimal) val ds = sqlContext.createDataset(List(X2(BigDecimal(-0.1267333984375), BigDecimal(-1000.1)))) val result = ds.select(ds("a") * ds("b")).collect.head println(result) // [null] }
Attachments
Issue Links
- is duplicated by
-
SPARK-24606 Decimals multiplication and division may be null due to the result precision overflow
- Resolved
- is related to
-
SPARK-23179 Support option to throw exception if overflow occurs during Decimal arithmetic
- Resolved
- relates to
-
HIVE-15331 Decimal multiplication with high precision/scale often returns NULL
- Closed
- links to
(1 links to)