#!/bin/bash
/opt/cloudera/parcels/CDH-5.15.1-1.cdh5.15.1.p0.4/bin/sqoop import --connect jdbc:oracle:thin:@193.1.100.1:1521:hiatmpdb --username haikang --password haikang -m 3 --target-dir /kakou/ods/VIO_VIOLATION_PIC_DAY_ODS --delete-target-dir --fields-terminated-by "^" --lines-terminated-by "\n" --hive-drop-import-delims --split-by CADDRESSCODE --where "1=1" --query """SELECT result.*, to_char(result.export_time,'yyyy-MM-dd') as day ,to_char(result.export_time,'yyyy-MM') as month FROM wf_haikang result where result.dillegaldate between sysdate-20 and sysdate and  result.export_time between to_date(to_char(sysdate-1,'yyyy-mm-dd'), 'yyyy-mm-dd') and to_date(to_char(sysdate,'yyyy-mm-dd'), 'yyyy-mm-dd') and \$CONDITIONS"""
/opt/cloudera/parcels/CDH-5.15.1-1.cdh5.15.1.p0.4/bin/hive -e "LOAD DATA INPATH '/kakou/ods/VIO_VIOLATION_PIC_DAY_ODS' INTO TABLE kakou.vio_violation_pic_day_ods"
/opt/cloudera/parcels/CDH-5.15.1-1.cdh5.15.1.p0.4/bin/hive -e "INSERT into ods.hbase_viopic SELECT concat_ws('#',ccarnumber,clicensetype,substr(dillegaldate,0,19),coffense),ccarnumber,clicensetype,caddresscode,cillegaladdress,coffense,dillegaldate,cpic1path,cpic2path,cpic3path,export_time,month,day  from kakou.vio_violation_pic_day_ods"
/opt/cloudera/parcels/CDH-5.15.1-1.cdh5.15.1.p0.4/bin/hive -e "insert into kakou.vio_violation_pic_his_ods PARTITION(day) SELECT CCARNUMBER,CLICENSETYPE,CADDRESSCODE,CILLEGALADDRESS,COFFENSE,DILLEGALDATE,CPIC1PATH,CPIC2PATH,CPIC3PATH,export_time,month,day from  kakou.vio_violation_pic_day_ods DISTRIBUTE BY rand()" --hiveconf hive.exec.dynamic.partition.mode=nonstrict --hiveconf hive.exec.dynamic.partition=true --hiveconf hive.exec.max.dynamic.partitions=36600 --hiveconf hive.exec.max.dynamic.partitions.pernode=36600