Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-22036

BigDecimal multiplication sometimes returns null

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.3.0
    • Component/s: SQL
    • Labels:
      None

      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

            Activity

              People

              • Assignee:
                mgaido Marco Gaido
                Reporter:
                OlivierBlanvillain Olivier Blanvillain
              • Votes:
                1 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: