@@ -66,6 +66,7 @@ BIGINT, REAL, DOUBLE or VARCHAR is supported. Casting to ARRAY and MAP is
6666supported when the element type of the array is one of the supported types, or
6767when the key type of the map is BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT,
6868REAL, DOUBLE, or VARCHAR and value type of the map is one of the supported types.
69+ When casting from JSON to ROW, both JSON array and JSON object are supported.
6970Behaviors of the casts are shown with the examples below:
7071
7172::
@@ -80,6 +81,8 @@ Behaviors of the casts are shown with the examples below:
8081 SELECT CAST(JSON '[1,null,456]' AS ARRAY(INTEGER)); -- [1, NULL, 456]
8182 SELECT CAST(JSON '[[1,23],[456]]' AS ARRAY(ARRAY(INTEGER))); -- [[1, 23], [456]]
8283 SELECT CAST(JSON '{"k1":1,"k2":23,"k3":456}' AS MAP(VARCHAR, INTEGER)); -- {k1=1, k2=23, k3=456}
84+ SELECT CAST(JSON '{"v1":123,"v2":"abc","v3":true}' AS ROW(v1 BIGINT, v2 VARCHAR, v3 BOOLEAN)); -- {v1=123, v2=abc, v3=true}
85+ SELECT CAST(JSON '[123,"abc",true]' AS ROW(v1 BIGINT, v2 VARCHAR, v3 BOOLEAN)); -- {v1=123, v2=abc, v3=true}
8386
8487Notice that casting a JSON text to VARCHAR does not turn the JSON text into
8588a plain string as is. Instead, it returns the VARCHAR string represented by
@@ -153,9 +156,8 @@ JSON Functions
153156 SELECT json_size('{"x": [1, 2, 3]}', '$.x'); -- 3
154157 SELECT json_size('{"x": {"a": 1, "b": 2}}', '$.x.a'); -- 0
155158
156- ============
157159JSON Vectors
158- ============
160+ ------------
159161
160162There are a number of Presto JSON functions expecting JSON-typed inputs or
161163returning JSON-typed outputs. Hence, developers who use the Velox library may
0 commit comments