改写成hive语法 update "rpt_wjq_jf_value_dhfz_list" as "a" set "a"."club_level" = '0星'; commit work; update "rpt_wjq_jf_value_dhfz_list" as "a" set "a"."club_level" = case when "b"."star_level" = '3100' then '1星' when "b"."star_level" = '3200' then '2星' when "b"."star_level" = '3300' then '3星' when "b"."star_level" = '3400' then '4星' when "b"."star_level" = '3500' then '5星' when "b"."star_level" = '3600' then '6星' when "b"."star_level" = '3700' then '7星' else '0星' end from "rptdev"."rpt_comm_cm_serv_cdma" as "b" where "a"."cust_id" = "b"."cust_id";
时间: 2023-07-02 19:10:21 浏览: 71
test_hive.rar_ThriftHive.php_hive_hive php_php hive_php hive Thr
抱歉,Hive不支持Update操作,只支持Insert、Select和Create等操作。如果需要更新数据,需要先创建一个新表,然后将旧表的数据插入到新表中。以下是可能的Hive语法:
```
-- 创建新表
CREATE TABLE new_rpt_wjq_jf_value_dhfz_list AS
SELECT a.*,
CASE
WHEN b.star_level = '3100' THEN '1星'
WHEN b.star_level = '3200' THEN '2星'
WHEN b.star_level = '3300' THEN '3星'
WHEN b.star_level = '3400' THEN '4星'
WHEN b.star_level = '3500' THEN '5星'
WHEN b.star_level = '3600' THEN '6星'
WHEN b.star_level = '3700' THEN '7星'
ELSE '0星'
END AS club_level
FROM rpt_wjq_jf_value_dhfz_list a
JOIN rpt_comm_cm_serv_cdma b ON a.cust_id = b.cust_id;
-- 删除旧表
DROP TABLE rpt_wjq_jf_value_dhfz_list;
-- 重命名新表
ALTER TABLE new_rpt_wjq_jf_value_dhfz_list RENAME TO rpt_wjq_jf_value_dhfz_list;
```
阅读全文