A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.databricks.com/aws/en/sql/language-manual/functions/from_json below:

from_json function | Databricks Documentation

from_json function

Applies to: Databricks SQL Databricks Runtime

Returns a struct value with the jsonStr and schema.

Syntax​
from_json(jsonStr, schema [, options])
Arguments​

jsonStr should be well-formed with respect to schema and options.

The schema must be defined as comma-separated column names and data type pairs, similar to the format used in CREATE TABLE. Prior to Databricks Runtime 12.2 schema must be a literal.

Alternatively, you can use from_json with Lakeflow Declarative Pipelines to automatically infer and evolve the schema by setting schema to NULL and specifying a schemaLocationKey. For examples, see Infer and evolve the schema using from_json in Lakeflow Declarative Pipelines.

note

The column and field names in schema are case-sensitive and must match the names in jsonStr exactly. To map JSON fields which differ only in case, you can cast the resulting struct to distinct field names. See Examples for more details.

options, if provided, can be any of the following:

Returns​

A struct with field names and types matching the schema definition.

Examples​

SQL

> SELECT from_json('{"a":1, "b":0.8}', 'a INT, b DOUBLE');
{"a":1,"b":0.8}

-- The column name must to match the case of the JSON field
> SELECT from_json('{"a":1}', 'A INT');
{"A":null}

> SELECT from_json('{"datetime":"26/08/2015"}', 'datetime Timestamp', map('timestampFormat', 'dd/MM/yyyy'));
{"datetime":2015-08-26 00:00:00}

-- Disambiguate field names with different cases
> SELECT cast(from_json('{"a":1, "A":0.8}', 'a INT, A DOUBLE') AS STRUCT<a: INT, b: DOUBLE>);
{"a":1, "b":0.8}
Related​

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4