使用orc文件格式优点 1.批处理中使用 msck repair table big_data_selection.{hive_tb}; alter table big_data_selection.{hive_tb} partition (key = "{value}") concatenate; 语句可以自动合并大量小文件 使用以下sqoop语句导入数据到hive本地表 utils.common_util.CommonUtil.build_hive_import_sh /opt/module/sqoop-1.4.6/bin/sqoop yswg_import -D mapred.job.queue.name=default -D mapred.task.timeout=0 \ --connect xx \ --username xx \ --password xx \ --query "query" \ --hcatalog-database xx \ --hcatalog-table xx \ --hcatalog-partition-keys xx \ --hcatalog-partition-values xx\ --hcatalog-storage-stanza "stored as orcfile" \ --m 1 \ --outdir "/tmp/sqoop/" 2.注意要点 1)orc文件格式自动合并小文件时必须是hive内部表 2)建表文件格式如下 create table `dim_st_pcp_history`(xxxxx) partitioned by ( `date_info` string comment '日期yyyy-mm-dd') row format serde 'org.apache.hadoop.hive.ql.io.orc.OrcSerde' stored as inputformat 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' outputformat 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat' location 'xxxxxxxxxxxxx'; 3)注意orc文件表格式不推荐表schema变动,否则读取时会有其他异常如果是新增字段保持旧schema同新schema格式兼容需要设置 spark.sql.orc.mergeSchema=true 参数