1.第一種方法 當存儲路徑與表所在路徑不一致時,可以load進去,如果表中字段類型不對應,該字段的值將會為空
load data inpath 'hdfs://hadoop01:9000/tmp/sales_info.txt' overwrite into table sales_info partition(dt = '20191215');
2.當存儲路徑與表所在路徑一致時,可以采用添加分區的方式
alter table ods_nshop.ods_01_releasedatas add partition (bdp_day='20191215') location 'hdfs://hadoop01:9000/data/nshop/ods/release/bdp_day=20191215'
hive的表如下:
create external table if not exists ods_nshop.ods_01_releasedatas(
customer_id string comment '用戶id',
device_num string comment '設備號',
device_type string comment '設備類型',
os string comment '手機系統',
os_version string comment '手機系統版本',
manufacturer string comment '手機制造商',
area_code string comment '地區編碼',
release_sid string comment '投放請求id',
release_session string comment '投放會話id',
release_sources string comment '投放渠道',
release_params string comment '投放請求參數',
ct bigint comment '創建時間'
)
partitioned by (bdp_day string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
stored as textfile
location '/data/nshop/ods/release/'