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

Pivot with null as the pivot value throws NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.2.0
    • 2.2.0
    • SQL
    • None

    Description

      This seems a regression.

      • Spark 1.6
      Seq(Tuple1(None), Tuple1(Some(1))).toDF("a").groupBy($"a").pivot("a").count().show()
      

      prints

      +----+----+---+
      |   a|null|  1|
      +----+----+---+
      |null|   0|  0|
      |   1|   0|  1|
      +----+----+---+
      
      • Current master
      Seq(Tuple1(None), Tuple1(Some(1))).toDF("a").groupBy($"a").pivot("a").count().show()
      

      prints

      java.lang.NullPointerException was thrown.
      java.lang.NullPointerException
        at org.apache.spark.sql.catalyst.expressions.aggregate.PivotFirst$$anonfun$4.apply(PivotFirst.scala:145)
        at org.apache.spark.sql.catalyst.expressions.aggregate.PivotFirst$$anonfun$4.apply(PivotFirst.scala:143)
        at scala.collection.immutable.List.map(List.scala:273)
        at org.apache.spark.sql.catalyst.expressions.aggregate.PivotFirst.<init>(PivotFirst.scala:143)
        at org.apache.spark.sql.catalyst.analysis.Analyzer$ResolvePivot$$anonfun$apply$7$$anonfun$24.apply(Analyzer.scala:509)
      

      Attachments

        Activity

          People

            a1ray Andrew Ray
            gurwls223 Hyukjin Kwon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: