You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2018/07/23 01:19:00 UTC
[jira] [Resolved] (SPARK-22228) Add support for
Array so from_json can parse
[ https://issues.apache.org/jira/browse/SPARK-22228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hyukjin Kwon resolved SPARK-22228.
----------------------------------
Resolution: Duplicate
> Add support for Array<primitive_type> so from_json can parse
> ------------------------------------------------------------
>
> Key: SPARK-22228
> URL: https://issues.apache.org/jira/browse/SPARK-22228
> Project: Spark
> Issue Type: Improvement
> Components: Java API
> Affects Versions: 2.2.0
> Reporter: kant kodali
> Priority: Major
>
> {code:java}
> val inputDS = Seq("""["foo", "bar"]""").toDF
> {code}
> {code:java}
> inputDS.printSchema()
> root
> |-- value: string (nullable = true)
> {code}
> Input Dataset inputDS
> {code:java}
> inputDS.show(false)
> value
> -----
> ["foo", "bar"]
> {code}
> Expected output dataset outputDS
> {code:java}
> value
> -------
> "foo" |
> "bar" |
> {code}
> Tried explode function like below but it doesn't quite work
> {code:java}
> inputDS.select(explode(from_json(col("value"), ArrayType(StringType))))
> {code}
> and got the following error
> {code:java}
> org.apache.spark.sql.AnalysisException: cannot resolve 'jsontostructs(`value`)' due to data type mismatch: Input schema string must be a struct or an array of structs
> {code}
> Also tried the following
> {code:java}
> inputDS.select(explode(col("value")))
> {code}
> And got the following error
> {code:java}
> org.apache.spark.sql.AnalysisException: cannot resolve 'explode(`value`)' due to data type mismatch: input to function explode should be array or map type, not StringType
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org