You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Maxim Gekk (JIRA)" <ji...@apache.org> on 2018/07/01 09:42:00 UTC

[jira] [Created] (SPARK-24709) Inferring schema from JSON string literal

Maxim Gekk created SPARK-24709:
----------------------------------

             Summary: 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


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: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org