是,亚马逊红移支持与“JSON_EXTRACT_PATH_TEXT”功能的列中解析JSON字符串,你可以调用这个函数即使在BY子句条款或组。最好看下面的例子来理解它是如何工作的。
db=> create table json_test (id int primary key, json text);
db=> insert into json_test values (1, '{"key1":1, "key2":"a"}');
db=> insert into json_test values (2, '{"key1":2, "key2":"b"}');
db=> insert into json_test values (3, '{"key1":3, "key2":"a"}');
db=> insert into json_test values (4, '{"key3":0}');
db=> select * from json_test order by id;
id | json
----+------------------------
1 | {"key1":1, "key2":"a"}
2 | {"key1":2, "key2":"b"}
3 | {"key1":3, "key2":"a"}
4 | {"key3":0}
(4 rows)
-- In select list
db=> select json_extract_path_text(json, 'key2') as key2 from json_test where id = 1;
key2
------
a
(1 row)
-- Where clause
db=> select * from json_test where json_extract_path_text(json, 'key1') = 1;
id | json
----+------------------------
1 | {"key1":1, "key2":"a"}
(1 row)
-- Group by
db=> select min(id) as min_id from json_test group by json_extract_path_text(json, 'key2') order by min_id;
min_id
--------
1
2
4
(3 rows)
有关“JSON_EXTRACT_PATH_TEXT”函数的详细信息,请参见Redshift Dev Guide - JSON_EXTRACT_PATH_TEXT Function。 您还可以在Redshift Dev Guide - JSON Functions中看到其他JSON函数。
只见那,不知道是否能回答我的要求,我是否可以在where子句中使用它(由于技术原因,我还没有动手一个RS DB)。 – user2339344 2014-10-28 19:30:57