小白之路------将greenplum的数据导入到hive的分区表
总体思路:greenplum中的数据不能直接导入hive中的分区表,可以在hive中先建一张没有分区的表来接收greenplum中的数据
再利用hive中的动态分区,将数据从hive表导入到hive分区表
步骤一
使用sqoop将数据从greenplum中的表导入到hive中的一张没有分区的表
sqoop脚本:
sqoop import “-Dorg.apache.sqoop.splitter.allow_text_splitter=true”
–connect “jdbc:pivotal:greenplum://ip地址:5432;DatabaseName=数据库名”
–driver com.pivotal.jdbc.GreenplumDriver
–username srv_dwbi03_fw
–password PoZxLU9G
–query " " \ //这里面是sql
–as-textfile --split-by “csp_id”
–fields-terminated-by ‘\t’
–delete-target-dir --num-mappers 1
–outdir /tmp
–target-dir /user/hive/warehouse/ges.db/ky_ph_test \ //hive表的hdfs路径,没有分区的表哦
–null-string ‘\N’
–null-non-string ‘\N’ \
步骤二
进入Hive客户端动态分区
hql:
set hive.optimize.sort.dynamic.partition =true;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set mapreduce.map.java.opts=-Xmx6114m;
set mapreduce.

本文详细介绍了如何将Greenplum中的数据导入到Hive的分区表。首先通过Sqoop将Greenplum数据导入到Hive的一张无分区表,然后在Hive客户端使用动态分区将数据插入到目标分区表。过程中需要注意数据量大可能导致的效率问题和动态分区错误,需分批处理并调整参数设置。
最低0.47元/天 解锁文章
2058

被折叠的 条评论
为什么被折叠?



