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

Datasets generate random values for null primitive types

    XMLWordPrintableJSON

    Details

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

      Description

      Not sure if it ever were reported.

      scala> val s = sc.parallelize(Seq[Option[Long]](None,Some(1L),Some(5))).toDF("v")
      s: org.apache.spark.sql.DataFrame = [v: bigint]
      
      scala> s.show(false)
      +----+
      |v   |
      +----+
      |null|
      |1   |
      |5   |
      +----+
      
      
      scala> s.as[Long].map(v => v*2).show(false)
      +-----+
      |value|
      +-----+
      |-2   |
      |2    |
      |10   |
      +-----+
      
      
      scala> s.select($"v"*2).show(false)
      +-------+
      |(v * 2)|
      +-------+
      |null   |
      |2      |
      |10     |
      +-------+
      

        Attachments

          Activity

            People

            • Assignee:
              cloud_fan Wenchen Fan
              Reporter:
              kuzemchik Vladislav Kuzemchik
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: