小白之路------将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.dyn