spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wenchen Fan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SPARK-19056) Row encoder should accept optional types
Date Tue, 03 Jan 2017 12:59:58 GMT

    [ https://issues.apache.org/jira/browse/SPARK-19056?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15795013#comment-15795013
] 

Wenchen Fan commented on SPARK-19056:
-------------------------------------

This is intentional. Allowing `Option` in `Row` is never documented and brings a lot of troubles
when we apply the encoder framework to all typed operations. Since Spark 2.0, please use `Dataset`
for typed operation/custom objects. e.g.
{code}
val ds = Seq(1 -> None, 2 -> Some("str")).toDS
ds.toDF // schema: <_1: int, _2: string>
{code}

> Row encoder should accept optional types
> ----------------------------------------
>
>                 Key: SPARK-19056
>                 URL: https://issues.apache.org/jira/browse/SPARK-19056
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0
>            Reporter: e89ff95a
>
> Since Spark 2.0 Spark doesn't accept optional types with `RowEncoder`:
> {code}
> import org.apache.spark.sql.types._
> import org.apache.spark.sql.Row
> spark.createDataFrame(
>   sc.parallelize(Seq(Row(None))),
>   StructType(Seq(StructField("v", StringType, true)))
> ).first
> // Caused by: java.lang.RuntimeException: Error while encoding: java.lang.RuntimeException:
scala.None$ is not a valid external type for schema of string
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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


Mime
View raw message