当前位置:   article > 正文

hive分区数据批量导入_hive批量insert

hive批量insert
1.一般导入分区数据用:
insert into table target_table partition (store_day=20200303) 
select column1,column2 from source_table where store_day=20200303;
  • 1
  • 2

但如果有很多个分区,逐个导的话很麻烦,而且每个分区一个job,要执行很多个jpb,效率很低。

2.批量导入可以这样
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.dynamic.partition=true;
insert into table target_table partition (store_day) 
select column1,column2,store_day from source_table where store_day >= 20190101 distribute by store_day;
  • 1
  • 2
  • 3
  • 4
3.两者区别
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.dynamic.partition=true;
  • 1
  • 2

这两句不能少,select 中也要加上partition 列,末尾加上distribute by。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/810415
推荐阅读
相关标签
  

闽ICP备14008679号