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

collect_set should ignore null values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1, 2.1.0
    • SQL
    • None

    Description

      `collect_set` throws the following exception when there are null values. It should ignore null values to be consistent with other aggregation methods.

      select collect_set(null) from (select 1) tmp;
      
      java.lang.IllegalArgumentException: Flat hash tables cannot contain null elements.
      	at scala.collection.mutable.FlatHashTable$HashUtils$class.elemHashCode(FlatHashTable.scala:390)
      	at scala.collection.mutable.HashSet.elemHashCode(HashSet.scala:41)
      	at scala.collection.mutable.FlatHashTable$class.addEntry(FlatHashTable.scala:136)
      	at scala.collection.mutable.HashSet.addEntry(HashSet.scala:41)
      	at scala.collection.mutable.HashSet.$plus$eq(HashSet.scala:60)
      	at scala.collection.mutable.HashSet.$plus$eq(HashSet.scala:41)
      	at org.apache.spark.sql.catalyst.expressions.aggregate.Collect.update(collect.scala:64)
      	at org.apache.spark.sql.execution.aggregate.AggregationIterator$$anonfun$1$$anonfun$applyOrElse$1.apply(AggregationIterator.scala:170)
      	at org.apache.spark.sql.execution.aggregate.AggregationIterator$$anonfun$1$$anonfun$applyOrElse$1.apply(AggregationIterator.scala:170)
      	at org.apache.spark.sql.execution.aggregate.AggregationIterator$$anonfun$generateProcessRow$1.apply(AggregationIterator.scala:186)
      	at org.apache.spark.sql.execution.aggregate.AggregationIterator$$anonfun$generateProcessRow$1.apply(AggregationIterator.scala:180)
      	at org.apache.spark.sql.execution.aggregate.SortBasedAggregationIterator.processCurrentSortedGroup(SortBasedAggregationIterator.scala:115)
      	at org.apache.spark.sql.execution.aggregate.SortBasedAggregationIterator.next(SortBasedAggregationIterator.scala:150)
      	at org.apache.spark.sql.execution.aggregate.SortBasedAggregationIterator.next(SortBasedAggregationIterator.scala:29)
      	at org.apache.spark.sql.execution.SparkPlan$$anonfun$3.apply(SparkPlan.scala:232)
      	at org.apache.spark.sql.execution.SparkPlan$$anonfun$3.apply(SparkPlan.scala:225)
      

      cc: yhuai

      Attachments

        Activity

          People

            mengxr Xiangrui Meng
            mengxr Xiangrui Meng
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: