目的:hive外部表使用mysql的某个字段作为分区字段或者某个字段的处理后的值作为分区字段.
思路:
先sqoop 导入到hive临时表,然后再导入到hive分区表
1 建hive外部表
CREATE external TABLE `ceshi.ods_asset` (
`ID` bigint,
`CLIENT_ID` bigint COMMENT '客户id',
`CLIENT_NUMBER` int COMMENT '客户编号',
`DELIVERY_NUMBER` string COMMENT '发货号'
) comment '产品销售表'
partitioned by (delivery_date int comment '发货日期')
stored as parquet
location '/warehouse/ppn2/ods/ods_asset'
tblproperties("parquet.compression"="snappy");
2 导入mysql到hive临时表
sqoop import \
--connect jdbc:mysql://192.168.100.11:3306/ceshidb?characterEncoding=utf-8 \
--username aaa\
--password bbb\
--delete-target-dir \
--table asset \