赞
踩
需求描述:最近在做数据清洗的工作,从ods层到dwd层对数据进行标准化。有多张表需要汇入主题表,因为表中的字段比较多,况且也不统一,需要从指定字段拿数据,并且清洗,最后汇入主题表。
- # 使用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的顺序,本人就是在这里踩了坑,谨记。
- # 使用overwrite时,是覆盖数据,into是追加数据,但是需要注意的是,overwrite后面的table不能省略而且不能指定字段名
- insert overwrite table partition(ptr='day')
- select id,name,age,gender from people;
PS:又结束了一天忙碌的工作,祝愿大家开心生活每一天。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。