energy_hive.sql 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. create database saga_dw location "/saga/saga_dw";
  2. /** 能源原始数据 15min 差值 */
  3. create table ods_energy_15_min
  4. (
  5. building string,
  6. func_id string,
  7. meter string,
  8. data_time string,
  9. data_value decimal(30, 15)
  10. ) COMMENT '能源原始数据15min差值数据'
  11. PARTITIONED BY (`dt` string)
  12. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  13. STORED AS TEXTFILE
  14. LOCATION
  15. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_energy_15_min'
  16. TBLPROPERTIES (
  17. 'orc.compress'='lzo');
  18. /** 能源数据 15min */
  19. create table ods_energy_15_min_fjd
  20. (
  21. building string,
  22. func_id string,
  23. meter string,
  24. data_time string,
  25. data_value decimal(30, 15)
  26. ) COMMENT '能源原始数据 15min'
  27. PARTITIONED BY (`dt` string)
  28. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  29. STORED AS TEXTFILE
  30. LOCATION
  31. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_energy_15_min_fjd'
  32. TBLPROPERTIES (
  33. 'orc.compress'='lzo');
  34. /** 能源数据按小时 */
  35. create table saga_dw.dwd_energy_15_min_hour
  36. (
  37. building string,
  38. func_id string,
  39. branch_type string,
  40. branch_type_name string,
  41. use_range_type string,
  42. value_sum decimal(30, 15),
  43. current_hour string comment '小时',
  44. current_year integer comment '年份',
  45. year_mouth string comment '年份-月份',
  46. week_of_year integer comment '这一年的第几周'
  47. ) COMMENT '能源原始数据15min按小时维度数据'
  48. PARTITIONED BY (`dt` string)
  49. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  50. STORED AS TEXTFILE
  51. LOCATION
  52. 'hdfs://HDFS85113:8020/saga/saga_dw/dwd/dwd_energy_15_min_hour'
  53. TBLPROPERTIES (
  54. 'orc.compress' = 'lzo');
  55. /** CO2 15min 分精度 */
  56. create table ods_co2_15_min
  57. (
  58. building string,
  59. func_id string,
  60. meter string,
  61. data_time string,
  62. data_value decimal(30, 15)
  63. ) COMMENT 'CO2 15min 分精度'
  64. PARTITIONED BY (`dt` string)
  65. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  66. STORED AS TEXTFILE
  67. LOCATION
  68. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_co2_15_min'
  69. TBLPROPERTIES (
  70. 'orc.compress'='lzo');
  71. /** PM2.5 15min 分精度 */
  72. create table ods_pm25_15_min
  73. (
  74. building string,
  75. func_id string,
  76. meter string,
  77. data_time string,
  78. data_value decimal(30, 15)
  79. ) COMMENT 'PM2.5 15min 分精度'
  80. PARTITIONED BY (`dt` string)
  81. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  82. STORED AS TEXTFILE
  83. LOCATION
  84. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_pm25_15_min'
  85. TBLPROPERTIES (
  86. 'orc.compress'='lzo');
  87. /** 甲醛 15 分钟分精度 */
  88. create table ods_hcho_15_min
  89. (
  90. building string,
  91. func_id string,
  92. meter string,
  93. data_time string,
  94. data_value decimal(30, 15)
  95. ) COMMENT '甲醛 15 分钟分精度'
  96. PARTITIONED BY (`dt` string)
  97. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  98. STORED AS TEXTFILE
  99. LOCATION
  100. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_hcho_15_min'
  101. TBLPROPERTIES (
  102. 'orc.compress'='lzo');
  103. /** 温度 15 分钟分精度 */
  104. create table ods_temperature_15_min
  105. (
  106. building string,
  107. func_id string,
  108. meter string,
  109. data_time string,
  110. data_value decimal(30, 15)
  111. ) COMMENT '温度 15 分钟分精度'
  112. PARTITIONED BY (`dt` string)
  113. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  114. STORED AS TEXTFILE
  115. LOCATION
  116. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_temperature_15_min'
  117. TBLPROPERTIES (
  118. 'orc.compress'='lzo');
  119. /** 湿度 15 分钟分精度 */
  120. create table ods_humidity_15_min
  121. (
  122. building string,
  123. func_id string,
  124. meter string,
  125. data_time string,
  126. data_value decimal(30, 15)
  127. ) COMMENT '湿度 15 分钟分精度'
  128. PARTITIONED BY (`dt` string)
  129. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  130. STORED AS TEXTFILE
  131. LOCATION
  132. 'hdfs://HDFS85113:8020/saga/saga_dw/ods/ods_humidity_15_min'
  133. TBLPROPERTIES (
  134. 'orc.compress'='lzo');