clickhouse_central_update_20241010.sql 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. create table tb_promotion_report
  2. (
  3. company String default '' comment '广告平台',
  4. advertiser_id String default '' comment '广告主id',
  5. gid String default '' comment '广告组id',
  6. aid String default '' comment '广告id',
  7. cid String default '' comment '广告创意id',
  8. cost Float64 default 0 comment '消耗(元)',
  9. show Int32 default 0 comment '展现(次)',
  10. click Int32 default 0 comment '点击(次)',
  11. convert Int32 default 0 comment '转化(个)',
  12. convert_cost Float64 default 0 comment '每个转化所付出的平均成本(元)',
  13. avg_show_cost Float64 default 0 comment '平均千次展现费用(元)',
  14. avg_click_cost Float64 default 0 comment '平均点击单价',
  15. time_granularity String default '' comment '时间维度DAILY或HOURLY',
  16. time_number Int64 default 0 comment '数据时间yyyyMMdd或yyyyMMddHH',
  17. add_timestamp Int64 default 0 comment '数据插入时间'
  18. )
  19. engine = ReplacingMergeTree
  20. PARTITION BY time_number
  21. ORDER BY (company, advertiser_id, gid, aid, cid, time_granularity, time_number)
  22. SETTINGS index_granularity = 8192;
  23. create table tb_promotion_report_rolling
  24. (
  25. company String default '' comment '广告平台',
  26. advertiser_id String default '' comment '广告主id',
  27. gid String default '' comment '广告组id',
  28. aid String default '' comment '广告id',
  29. cid String default '' comment '广告创意id',
  30. cost Float64 default 0 comment '消耗(元)',
  31. show Int32 default 0 comment '展现(次)',
  32. click Int32 default 0 comment '点击(次)',
  33. convert Int32 default 0 comment '转化(个)',
  34. convert_cost Float64 default 0 comment '每个转化所付出的平均成本(元)',
  35. avg_show_cost Float64 default 0 comment '平均千次展现费用(元)',
  36. avg_click_cost Float64 default 0 comment '平均点击单价',
  37. time_granularity String default '' comment '时间维度DAILY或HOURLY',
  38. time_number Int64 default 0 comment '数据时间yyyyMMdd或yyyyMMddHH',
  39. add_timestamp Int64 default 0 comment '数据插入时间'
  40. )
  41. engine = ReplacingMergeTree
  42. PARTITION BY time_number
  43. ORDER BY (company, advertiser_id, gid, aid, cid, time_granularity, time_number)
  44. TTL toDateTime(add_timestamp / 1000) + interval 3 day
  45. SETTINGS index_granularity = 8192;