我查询齐柏林飞艇上的test_tbl表。表数据结构如下所示:
%sql
desc stg.test_tbl
col_name | data_type | comment
id | string |
title | string |
tags | string |
标签列的数据JSON类型如下:
{“ name”:[{“ family”:null,“ first”:“ nelson”},{“ pos_code”:{“ house”:“ tlv”,“ id”:“ A12YR”}}}}}]] >
而且我想查看带有列的JSON数据,所以我的查询是:
select *, tag.* from stg.test_tbl as t lateral view explode(t.tags.name) name as name lateral view explode(name.pos_code) pos_code as pos_code
但是当我查询时,它返回
Can't extract value from tags#3423: need struct type but got string; line 3 pos 21 set zeppelin.spark.sql.stacktrace = true to see full stacktrace
我应该在where语句中以字符串查询吗?
我查询齐柏林飞艇上的test_tbl表。表数据结构如下所示:%sql desc stg.test_tbl col_name | data_type |评论ID |字符串标题|字符串标签| ...
您可以使用JSON字符串类型的get_json_object。另外,如果JSON是数组类型,则为