You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2018/12/19 09:53:46 UTC

[GitHub] HyukjinKwon edited a comment on issue #23349: [SPARK-26403][SQL] Support pivoting using array column for `pivot(column)` API

HyukjinKwon edited a comment on issue #23349: [SPARK-26403][SQL] Support pivoting using array column for `pivot(column)` API
URL: https://github.com/apache/spark/pull/23349#issuecomment-448535079
 
 
   cc @cloud-fan
   
   During checking the codes, I found two things below that I would like to mention.
   
   1.. `Literal.create` already supports this when input type is explicit.
   
   ```scala
   scala> Literal.create(collection.mutable.WrappedArray.make(Array(1)))
   res0: org.apache.spark.sql.catalyst.expressions.Literal = [1]
   
   scala> Literal.create(collection.mutable.WrappedArray.make(Array(1)): Seq[Int])
   res1: org.apache.spark.sql.catalyst.expressions.Literal = [1]
   ```
   
   However, currently not when we don't know the type:
   
   ```scala
   scala> Literal.create(collection.mutable.WrappedArray.make(Array(1)): Any)
   java.lang.RuntimeException: Unsupported literal type class scala.collection.mutable.WrappedArray$ofInt WrappedArray(1)
     at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:79)
     at org.apache.spark.sql.catalyst.expressions.Literal$.$anonfun$create$2(literals.scala:171)
     at scala.util.Failure.getOrElse(Try.scala:222)
     at org.apache.spark.sql.catalyst.expressions.Literal$.create(literals.scala:171)
     ... 49 elided
   ```
   
   This PR also is going to fix it as below:
   
   ```scala
   scala> Literal.create(collection.mutable.WrappedArray.make(Array(1)): Any)
   res0: org.apache.spark.sql.catalyst.expressions.Literal = [1]
   ```
   
   2.. `Literal.apply` can't support `Seq[_]` for now:
   
   ```scala
   scala> Literal.apply(Seq(1))
   java.lang.RuntimeException: Unsupported literal type class scala.collection.immutable.$colon$colon List(1)
     at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:79)
     ... 49 elided
   ```
   
   I would like to leave these as a separate discussion out of this PR.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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