sqoop从关系库导出数据到hive

sqoop从关系库导出数据到hive

分类:HIVE/Hbase/Spark

sqoop

[Author]: kwu

sqoop从关系库导出数据到hive,sqoop支持条件查询关系库中的数到hive数据仓库中,并且字段无须与hive表中的字段一致。

具体实现的脚本:

#!/bin/sh # upload logs to hdfs today=`date –date='0 days ago' +%Y-%m-%d`sqoop import –connect jdbc:mysql://10.130.2.6:3306/bdc_test –username lvwenjuan –password Abcd1234 –table sh_compsite_index –where "V1='${today}'" –columns "V1,V2,V3,V4,V5,V6,V7" –fields-terminated-by '\001' –hive-import –hive-drop-import-delims –hive-table stage.sh_comp_index -m 1year=`date +%Y`hive -e " insert overwrite table ods.sh_comp_index partition(year='${year}')select distincttrans_date ,open_price ,ceil_price ,close_price ,bottom_price ,volume_of_business ,trans_amountfromstage.sh_comp_indexwhere year(trans_date)=${year}; "说明:

1、条件语句,需要加上双引号: "" ,如下:

–where "V1='${today}'"2、注意,sqoop的语句需要写成一行执行。

3、-m 1说明是一个map执行。

版权声明:本文为博主原创文章,,未经博主允许不得转载。

上一篇基于sparksql调用shell脚本执行SQL

顶2踩0

不是每个人都一定快乐,不是每种痛都一定要述说。

sqoop从关系库导出数据到hive

相关文章:

你感兴趣的文章:

标签云: