saga_dw_dim.sql 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- 支路维度
  2. create table saga_dw.dim_office_meter
  3. (
  4. id integer,
  5. meter integer comment '表号',
  6. branch_code string comment '支路编码',
  7. branch_name string comment '支路名称',
  8. branch_type string comment '支路类型',
  9. parent_code string comment '上级表编码',
  10. use_range_type string comment '控制区域',
  11. use_range string comment '区域范围'
  12. ) COMMENT '支路维度'
  13. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  14. STORED AS TEXTFILE
  15. LOCATION
  16. 'hdfs://sagaCluster:8020/warehouse/saga_dw/dim/dim_office_meter'
  17. TBLPROPERTIES (
  18. 'orc.compress' = 'lzo');
  19. -- 时间维度数据
  20. create table saga_dw.dim_date_day
  21. (
  22. date_id string,
  23. week_of_year integer comment '这一年的第几周',
  24. day_of_year integer comment '这一年的第几天',
  25. day_of_mouth integer comment '这一月的第几天',
  26. type string comment '0 工作日 1 假日 2 节假日',
  27. date_type string comment 'type 的英文',
  28. index_work_day_of_month integer comment '如果当前是工作日 则返回是当前月的第几个工作日,否则返回0',
  29. week_day integer comment '星期几',
  30. week_day_cn string comment '星期中文',
  31. week_day_en string comment '星期英文',
  32. current_year integer comment '年份',
  33. current_quarter integer comment '季度',
  34. year_quarter string comment '年份-季度',
  35. mouth integer comment '月份',
  36. year_mouth string comment '年份-月份',
  37. is_first_day_mouth integer comment '是当月第一天 0:false 1:true',
  38. is_last_day_mouth integer comment '是当月最后一天 0:false 1:true',
  39. type_des string comment '类型描述 比如 国庆,休息日,工作日'
  40. ) COMMENT '时间维度数据'
  41. ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001'
  42. STORED AS TEXTFILE
  43. LOCATION
  44. 'hdfs://sagaCluster:8020/warehouse/saga_dw/dim/dim_date_day'
  45. TBLPROPERTIES (
  46. 'orc.compress' = 'lzo');