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