select sum(cast(element as int)) as mysum,
--other columnt from t
from mytable t
lateral view outer explode(split(regexp_replace(col_name,'\\[|\\]|"',''),', *')) e as element
--group by other columns from t
字符串 如果是ARRAY<STRING>,则
select sum(cast(element as int)) as mysum,
--other columnt from t
from mytable t
lateral view outer explode(col_name) e as element
--group by other columns from t
1条答案
按热度按时间oyjwcjzk1#
如果您的列是STRING数据类型,那么您可以使用regexp_replace删除方括号和双引号,并使用split()拆分结果字符串以获得数组:
字符串
如果是
ARRAY<STRING>
,则型