saga_dw_dim.sql 2.0 KB

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