[Hive]Hive分区表新增字段

8 篇文章 0 订阅
hive (default)> desc pms.test_cross_sale_path;
OK
col_name    data_type   comment
path_id string  
visit_track_id  string  
visit_product_id    bigint  
visit_category_id   bigint  
visit_brand_id  bigint  
rcmd_track_id   string  
rcmd_product_id bigint  
rcmd_category_id    bigint  
rcmd_brand_id   bigint  
rcmd_algorithm_id   bigint  
cart_track_id   string  
cart_track_time string  
cart_product_id bigint  
cart_category_id    bigint  
cart_brand_id   bigint  
path_type   int 
path_length int 
path_list   string  
session_id  string  
gu_id   string  
end_user_id string  
ds  string  
Time taken: 3.159 seconds

在上表中新增两个字段platform_id、tpa,类型均为int类型

hive (pms)> alter table pms.test_cross_sale_path add columns(platform_id int, tpa int);
FAILED: ParseException line 1:12 cannot recognize input near 'pms' '.' 'test_cross_sale_path' in alter table statement

这样执行会有问题,数据库名默认不支持,换种写法即可

hive (pms)> use pms;                                                                   
OK
Time taken: 0.012 seconds
hive (pms)> alter table test_cross_sale_path add columns(platform_id int, tpa int);
OK
Time taken: 0.012 seconds

新增的字段将加到该表的最后,分区字段之前,并且在以前的分区中这两个字段都为NULL

hive (default)> desc pms.test_cross_sale_path;
OK
col_name	data_type	comment
path_id	string	
visit_track_id	string	
visit_product_id	bigint	
visit_category_id	bigint	
visit_brand_id	bigint	
rcmd_track_id	string	
rcmd_product_id	bigint	
rcmd_category_id	bigint	
rcmd_brand_id	bigint	
rcmd_algorithm_id	bigint	
cart_track_id	string	
cart_track_time	string	
cart_product_id	bigint	
cart_category_id	bigint	
cart_brand_id	bigint	
path_type	int	
path_length	int	
path_list	string	
session_id	string	
gu_id	string	
end_user_id	string	
platform_id	int	
tpa	int	
ds	string	
Time taken: 3.159 seconds

 

转载:https://blog.csdn.net/yeweiouyang/article/details/44851459

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值