sqoop从MySQL数据库导入hive中

本文介绍如何在ETL过程中利用sqoop工具将MySQL数据库中的表高效地导入到Hive中,并在迁移过程中添加插入时间和插入方式的额外字段。
摘要由CSDN通过智能技术生成
  • 需求场景
  1. 将MySQL中的某张表导入到hive中
  2. 需添加一些插入时间及插入方式的新字段
  • 代码
sqoop import \
-D sqoop.parquet.logical_types.decimal.enable=true \
-D parquetjob.configurator.implementation=hadoop \
-D sqoop.avro.decimal_padding.enable=true \
-D sqoop.avro.logical_types.decimal.default.precision=18 \
-D sqoop.avro.logical_types.decimal.default.scale=6 \
--connect 'jdbc:mysql://172.24.xxx.xxx:3306/xxxxxxx' \   #mysql服务器ip、数据库名
--username 'xxxxx' \   #mysql服务器登陆名
--password 'xxxxx' \   #密码
--query "select id,bukrs,butxt,'sqoop' ins_by,DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s') ins_dt from temp_company_entity where \$CONDITIONS" \  #查询语句
--fetch-size 1000 \
--delete-target-dir \
--target-dir /user/hive/warehouse/xxxxx/ods_sap_company_1d/p_dt=`date +%Y%m%d` \
--hive-drop-import-delims \
--hive-import \
--hive-overwrite \
--hive-database xxxxx \
--hive-table xxxxx \
--h
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值