ods_view_to_table.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. env_config="
  3. use saga_dw;
  4. SET mapreduce.job.queuename=hive;
  5. SET hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
  6. SET hive.exec.dynamic.partition.mode=nonstrict;"
  7. ods_energy_15_min="
  8. insert into saga_dw.ods_energy_15_min partition(dt)
  9. select
  10. building,
  11. func_id,
  12. meter,
  13. data_time,
  14. data_value,
  15. dt
  16. from saga_dw.ods_energy_15_min_history;"
  17. ods_energy_5_min="
  18. insert into saga_dw.ods_energy_5_min partition(dt)
  19. select
  20. building,
  21. func_id,
  22. meter,
  23. data_time,
  24. data_value,
  25. dt
  26. from saga_dw.ods_energy_5_min_history;"
  27. ods_energy_15_min_fjd="
  28. insert into saga_dw.ods_energy_15_min_fjd partition(dt)
  29. select
  30. building,
  31. func_id,
  32. meter,
  33. data_time,
  34. data_value,
  35. dt
  36. from saga_dw.ods_energy_15_min_fjd_history;"
  37. ods_energy_5_min_fjd="
  38. insert into saga_dw.ods_energy_5_min_fjd partition(dt)
  39. select
  40. building,
  41. func_id,
  42. meter,
  43. data_time,
  44. data_value,
  45. dt
  46. from saga_dw.ods_energy_5_min_fjd_history;"
  47. insert_into_table(){
  48. case $1 in
  49. "energy_15_min")
  50. echo $1
  51. hive -e "$env_config$ods_energy_15_min$ods_energy_15_min_fjd"
  52. ;;
  53. "energy_5_min")
  54. echo $1
  55. hive -e "$env_config$ods_energy_5_min$ods_energy_5_min_fjd"
  56. ;;
  57. "ods_energy_15_min")
  58. echo $1
  59. hive -e "$env_config$ods_energy_15_min"
  60. ;;
  61. "ods_energy_5_min")
  62. echo $1
  63. hive -e "$env_config$ods_energy_5_min"
  64. ;;
  65. "ods_energy_15_min_fjd")
  66. echo $1
  67. hive -e "$env_config$ods_energy_15_min_fjd"
  68. ;;
  69. "ods_energy_5_min_fjd")
  70. echo $1
  71. hive -e "$env_config$ods_energy_5_min_fjd"
  72. ;;
  73. esac
  74. }