Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17699] Support for parsing JSON string columns - #15274
Conversation
SparkQA
commented
Sep 28, 2016
Test build #66016 has finished for PR 15274 at commit
|
| /** | ||
| * Converts an json input string to a [[StructType]] with the specified schema. | ||
| */ | ||
| case class JsonToStruct(schema: StructType, options: Map[String, String], child: Expression) |
There was a problem hiding this comment.
Should this implement ExpectsInputTypes?
There was a problem hiding this comment.
Ah, yes, it definitly should. Let me update.
rxin
commented
Sep 28, 2016
Might want to send a dev list email to solicit feedback on the API? |
marmbrus
commented
Sep 28, 2016
Emailed the list. Seems like a popular feature so far :) |
SparkQA
commented
Sep 28, 2016
Test build #66048 has finished for PR 15274 at commit
|
SparkQA
commented
Sep 28, 2016
Test build #66052 has finished for PR 15274 at commit
|
HyukjinKwon
commented
Sep 29, 2016
@marmbrus I just wonder if adding |
yhuai
commented
Sep 29, 2016
LGTM. Merging to master. |
marmbrus
commented
Sep 29, 2016
@HyukjinKwon absolutely. I actually changed the name from |
@marmbrus: Is there any workaround I can use to achieve a similar effect in 1.6? |
yhuai
commented
Oct 17, 2016
@DanielMe The best options for 1.6 are |
DanielMe
commented
Oct 18, 2016
@yhuai thanks! My impression was that |
yhuai
commented
Oct 18, 2016
@DanielMe oh, I see. |
Actually, to specify the schema in SQL language, maybe we can use a JSON string. A little bit odd. So far, nobody is asking for it, I guess. Let us see whether users need it in SQL |
Sazpaimon
commented
Mar 4, 2017
@gatorsmile Alternatively, one can use do what brickhouse's (For the record, I actually need this in SQL) |
gatorsmile
commented
Mar 4, 2017
Based on the comment @marmbrus in a JIRA, we prefer to using our DDL format. For example, like what we did for CREATE TABLE, we can specify the schema using |
Spark SQL has great support for reading text files that contain JSON data. However, in many cases the JSON data is just one column amongst others. This is particularly true when reading from sources such as Kafka. This PR adds a new functions
from_jsonthat converts a string column into a nestedStructTypewith a user specified schema.Example usage:
This PR adds support for java, scala and python. I leveraged our existing JSON parsing support by moving it into catalyst (so that we could define expressions using it). I left SQL out for now, because I'm not sure how users would specify a schema.