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