-- | 1110 | [{"content":"全部内容。" }, { "content":"无其它特别约定。"}] |
select id, get_json_object(cl,'$.content') as content from (
select id, split(regexp_replace( regexp_extract (property_value ,'(\\[)(.*?)(\\])',2) ,'},{','}|{'),'\\|') as property_value
from properties where pt='20180627000000' and property_key ='specail' limit 1 ) b
lateral view explode(property_value) tf as cl
) b group by id ;
结果 :
+-------------------+----------+
| id | contents |+-------------------+----------+
| 1110 | 全部内容。||无其它特别约定。 |
+-------------------+----------+
具体步骤说明:
1。 抽取树组 中的json
2。 替换json分割符 为|
3。split()
4。lateral view explode(property_value) 列转行
5。行转列
是不是要疯了:好端端的一个树组 ,然后这么复杂才解析出来 ,并抽取出里面的字段 。
如果 property_value 以数组的形式存储 ,可以省掉前三步骤。