[
https://issues.apache.org/jira/browse/SPARK-24709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16529038#comment-16529038
]
Apache Spark commented on SPARK-24709:
--------------------------------------
User 'MaxGekk' has created a pull request for this issue:
https://github.com/apache/spark/pull/21686
> Inferring schema from JSON string literal
> -----------------------------------------
>
> Key: SPARK-24709
> URL: https://issues.apache.org/jira/browse/SPARK-24709
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 2.3.1
> Reporter: Maxim Gekk
> Priority: Minor
>
> Need to add new function - *schema_of_json()*. The function should infer
> schema of JSON string literal. The result of the function is a schema in DDL
> format.
> One of the use cases is passing output of _schema_of_json()_ to
> *from_json()*. Currently, the _from_json()_ function requires a schema as a
> mandatory argument. An user has to pass a schema as string literal in SQL.
> The new function should allow schema inferring from an example. Let's say
> json_col is a column containing JSON string with the same schema. It should
> be possible to pass a JSON string with the same schema to _schema_of_json()_
> which infers schema for the particular example.
> {code:sql}
> select from_json(json_col, schema_of_json('{"f1": 0, "f2": [0], "f2": "a"}'))
> from json_table;
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]