HyukjinKwon commented on a change in pull request #23349: [SPARK-26403][SQL] 
Support pivoting using array column for `pivot(column)` API
URL: https://github.com/apache/spark/pull/23349#discussion_r244658731
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/RelationalGroupedDataset.scala
 ##########
 @@ -422,10 +422,14 @@ class RelationalGroupedDataset protected[sql](
   def pivot(pivotColumn: Column, values: Seq[Any]): RelationalGroupedDataset = 
{
     groupType match {
       case RelationalGroupedDataset.GroupByType =>
-        val valueExprs = values.map(_ match {
+        val valueExprs = values.map {
           case c: Column => c.expr
+          // ArrayType returns a `WrappedArray` but currently `Literal.apply`
+          // does not support this type although it supports a normal array.
+          // Here manually unwrap to make it an array. See also SPARK-26403.
+          case v: collection.mutable.WrappedArray[_] => Literal.apply(v.array)
 
 Review comment:
   Yup.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to