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_r244539585
##########
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:
@cloud-fan, I didn't mean something special but this :).
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]