UNNEST ( string_to_array( ext_7, ',' ) ) AS ext_7替换为hive sql
时间: 2024-03-28 20:37:52 浏览: 65
使用Lateral View和Explode函数替换UNNEST和string_to_array函数,Hive SQL语句如下:
SELECT exploded_ext_7 AS ext_7
FROM table_name
LATERAL VIEW explode(split(ext_7,',')) exploded_ext_7;
相关问题
SELECT record_id, mid, UNNEST ( string_to_array( ext_7, ',' ) ) AS ext_7 FROM d_form_list_context_patrol_toadb_0419 替换为hivesql
使用Lateral View和Explode函数替换UNNEST和string_to_array函数,同时选择需要的字段,Hive SQL语句如下:
SELECT record_id, mid, exploded_ext_7 AS ext_7
FROM d_form_list_context_patrol_toadb_0419
LATERAL VIEW explode(split(ext_7,',')) exploded_ext_7;
select count(1) from (SELECT record_id, mid, UNNEST ( string_to_array( ext_7, ',' ) ) AS ext_7 FROM d_form_list_context_patrol_toadb_0419 WHERE check_result = 'check_no' 如何替换为hive sql
你的问题中给出的 SQL 语句是 PostgreSQL 的语法,如果要在 Hive 中实现同样的功能,可以使用以下 SQL 语句:
```
SELECT count(1) FROM
(SELECT record_id, mid, explode(split(ext_7, ',')) AS ext_7
FROM d_form_list_context_patrol_toadb_0419
WHERE check_result = 'check_no') t;
```
其中,`split` 函数用于将 ext_7 字段按逗号分隔成数组,`explode` 函数用于将数组的每个元素拆分成单独的行,然后就可以统计行数了。
阅读全文