12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #!/bin/bash
- . ./config.sh
- url=$MYSQL_URL
- username=$MYSQL_USER
- password=$MYSQL_PASSWORD
- ## 无分区
- import_no_partition() {
- sqoop import \
- -D mapred.job.queue.name=hive \
- --connect $1 \
- --username $2 \
- --password $3 \
- --target-dir $4$7 \
- --delete-target-dir \
- --columns "$5" \
- --query "$6 and \$CONDITIONS" \
- --num-mappers 1 \
- --hive-drop-import-delims \
- --fields-terminated-by '\001' \
- --compress \
- --compression-codec lzo \
- --hive-import \
- --hive-database saga_dw \
- --hive-table $7 \
- --hive-overwrite \
- --null-string '\\N' \
- --null-non-string '\\N'
- }
- ods_energy_15_min_history(){
- import_no_partition $url $username $password /warehouse/saga_dw/ods/ods_tmp_data/ "building, func_id, meter, data_time, data_value, dt" "select building, func_id, meter, data_time, data_value, dt from energy_15_min_history where 1 = 1" ods_energy_15_min_history
- }
- ods_energy_5_min_history(){
- import_no_partition $url $username $password /warehouse/saga_dw/ods/ods_tmp_data/ "building, func_id, meter, data_time, data_value, dt" "select building, func_id, meter, data_time, data_value, dt from energy_5_min_history where 1 = 1" ods_energy_5_min_history
- }
- ods_energy_15_min_fjd_history(){
- import_no_partition $url $username $password /warehouse/saga_dw/ods/ods_tmp_data/ "building, func_id, meter, data_time, data_value, dt" "select building, func_id, meter, data_time, data_value, dt from energy_15_min_fjd_history where 1 = 1" ods_energy_15_min_fjd_history
- }
- ods_energy_5_min_fjd_history(){
- import_no_partition $url $username $password /warehouse/saga_dw/ods/ods_tmp_data/ "building, func_id, meter, data_time, data_value, dt" "select building, func_id, meter, data_time, data_value, dt from energy_5_min_fjd_history where 1 = 1" ods_energy_5_min_fjd_history
- }
- case $1 in
- "energy_15_min")
- ods_energy_15_min_history
- ods_energy_15_min_fjd_history
- ;;
- "energy_5_min")
- ods_energy_5_min_history
- ods_energy_5_min_fjd_history
- ;;
- "ods_energy_15_min_history")
- ods_energy_15_min_history
- ;;
- "ods_energy_5_min_history")
- ods_energy_5_min_history
- ;;
- "ods_energy_15_min_fjd_history")
- ods_energy_15_min_fjd_history
- ;;
- "ods_energy_5_min_fjd_history")
- ods_energy_5_min_fjd_history
- ;;
- esac
|