一:创建hive表。
sql
--drop table if exists ods.odsyyy;
create table if not exists ods.odsfff(
row_id string comment '行记录唯一ID,对应ROW_KEY'
,aaa string comment 'aaa'
,bbb string comment 'bbb'
,ccc string comment 'ccc'
,ddd string comment 'ddd'
,create_time comment '创建时间'
,edit_time comment '更新时间'
)comment 'ods层数xxxx'
partitioned by (p_dt string comment '分区日期(yyyy-MM-dd)')
row format delimited
fields terminated by '\t'
collection items terminated by '\n'
stored as orc;`
二:将数据插入表。
insert overwrite table ods.odsyyy partition(p_dt='${dealDate}')
select
a.row_id
,a.aaa
,a.bbb
,a.ccc
,a.ddd
,a.create_time
,a.edit_time
from ods.ods_yyy_hb as a
WHERE (coalesce(to_date(a.create_time),'${dealDate}') <= '${dealDate}'
or coalesce(to_date(a.edit_time),'${dealDate}') <= '${dealDate}')
文章来源地址https://uudwc.com/A/gV3DG
文章来源:https://uudwc.com/A/gV3DG