0


hive:insert into/overwrite插入分区详解

需求描述:最近在做数据清洗的工作,从ods层到dwd层对数据进行标准化。有多张表需要汇入主题表,因为表中的字段比较多,况且也不统一,需要从指定字段拿数据,并且清洗,最后汇入主题表。

  1. insert into # 使用insert into时,属于是追加行为,如果指定字段,那么查询的字段要出插入列数一致示例:insert into table personnel(id,name,age,gender)select id,name,age,gender from people;# 由于我是分区表,还需要指定分区,这块当时给我困惑了好长时间insert into table personnel partition(ptr='day')(id,name,age,gender)select id,name,age,gender from people;说明:一定要注意partition的顺序,本人就是在这里踩了坑,谨记。
  2. insert overwrite # 使用overwrite时,是覆盖数据,into是追加数据,但是需要注意的是,overwrite后面的table不能省略而且不能指定字段名insert overwrite table partition(ptr='day')select id,name,age,gender from people;

PS:又结束了一天忙碌的工作,祝愿大家开心生活每一天。


本文转载自: https://blog.csdn.net/m0_46241543/article/details/134837804
版权归原作者 A杂家 所有, 如有侵权,请联系我们删除。

“hive:insert into/overwrite插入分区详解”的评论:

还没有评论