1、建表
drop table if exists tmp.dwd_df;
create table tmp.dwd_df as
select * from
dwd.dwd_df
where etl_date = 20230112 and 1=2
;
CREATE TABLE tmp.dm_df(
froms string,
tolist string,
createdatetime string)
row format delimited fields terminated by ‘,’ lines terminated by ‘\n’ stored as textfile;
2、指定分隔符,同时使用GBK防止中文乱码
ALTER TABLE tmp.dm_df SET SERDEPROPERTIES (‘field.delim’ = ‘,’, ‘serialization.format’=‘,’,‘serialization.encoding’=‘GBK’);
3、导入数据(执行前对hdfs文件增加读写权限)
LOAD DATA INPATH ‘/user/2-1-1-dm_df.csv’ overwrite INTO TABLE tmp.dm_df;