Github user hvanhovell commented on a diff in the pull request:
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
    @@ -53,7 +53,15 @@ import org.apache.spark.util.Utils
     private[sql] object Dataset {
       def apply[T: Encoder](sparkSession: SparkSession, logicalPlan: 
LogicalPlan): Dataset[T] = {
    -    new Dataset(sparkSession, logicalPlan, implicitly[Encoder[T]])
    +    val encoder = implicitly[Encoder[T]]
    +    if (encoder.clsTag.runtimeClass == classOf[Row]) {
    +      // We should use the encoder generated from the executed plan rather 
than the existing
    +      // encoder for DataFrame because the types of columns can be varied 
due to widening types.
    +      // See SPARK-17123. This is a bit hacky. Maybe we should find a 
better way to do this.
    +      ofRows(sparkSession, logicalPlan).asInstanceOf[Dataset[T]]
    +    } else {
    +      new Dataset(sparkSession, logicalPlan, encoder)
    +    }
    --- End diff --
    Yeah, I forgot about type widening.

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to