Sqoop在很长一段时间都只支持导入为textfile、avrofile、sequencefile等格式,如果需要将数据导入为ORC、parquet等格式的Hive Table往往需要分两个步骤完成(先导出临时表,再通过Hive转换)。而从Sqoop 1.4.4开始,Sqoop集成了HCatalog,我们可以轻易地实现多格式支持。
HCatalog配置
Sqoop需要依赖HCatalog的lib,所以需要配置环境变量$HCAT_HOME,一般从hive目录下即可找到hcatalog的相关路径
导入命令
sqoop import
--connect jdbc:mysql://127.0.0.1:3306/test
--username your_user_name --password your_passwd
--table table_name --driver com.mysql.jdbc.Driver
--create-hcatalog-table
--hcatalog-table table_name
--hcatalog-partition-keys month,day
--hcatalog-partition-values 12,09
--hcatalog-storage-stanza 'stored as orc tblproperties ("orc.compress"="SNAPPY")'