有个需求,需要在hive表里面追加数据,数据是历史数据,是业务方给的一个csv文件,
思路,考虑使用load data inpath,把历史数据导入到hive表里面
步骤:
2、创建一个表,表里面的字段名称和字段顺序,跟csv文件保持一致,例如这个表名叫 infor.load_data_test;
3、load data inpath 'hdfs://xxxxxx/user/hive/warehouse/export/xxx.csv' overwrite into table infor.load_data_test;
其中'hdfs://xxxxxx/user/hive/warehouse/export/xxx.csv',是文件上传后,存放的位置
4、把临时表的数据写入到正式的hive表中
INSERT into infor.formal_data_table
select field1,field2, 1597456800000 as create_time from infor.load_data_test;
加一个时间戳,标识这批数据是什么时候写入的