/* 报警表 */
create table alarm
(
  monitor_id String,
  alarm_start_time DateTime64 CODEC(DoubleDelta),
  alarm_type Int32,
  monitor_name SimpleAggregateFunction(max, LowCardinality(String)),
  speed SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  alarm_end_time SimpleAggregateFunction(max, DateTime64) CODEC(DoubleDelta),
  alarm_start_location SimpleAggregateFunction(max, LowCardinality(String)),
  alarm_end_location SimpleAggregateFunction(max, LowCardinality(String)),
  alarm_source SimpleAggregateFunction(max, Int8),
  push_type SimpleAggregateFunction(max, Int8),
  handle_status SimpleAggregateFunction(max, Int8),
  max_speed SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  speed_limit SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  severity SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  duration SimpleAggregateFunction(max, Int64),
  handle_type SimpleAggregateFunction(max, LowCardinality(String)),
  group_name SimpleAggregateFunction(max, LowCardinality(String)),
  professionals_name SimpleAggregateFunction(max, LowCardinality(String)),
  description SimpleAggregateFunction(max, LowCardinality(String)),
  fence_type SimpleAggregateFunction(max, LowCardinality(String)),
  fence_name SimpleAggregateFunction(max, LowCardinality(String)),
  monitor_type SimpleAggregateFunction(max, Int8),
  swift_number SimpleAggregateFunction(max, LowCardinality(String)),
  protocol_type SimpleAggregateFunction(max, Int8),
  cal_standard SimpleAggregateFunction(max, Int8),
  speed_type SimpleAggregateFunction(max, Int8),
  road_net_speed_limit SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  alt SimpleAggregateFunction(max, LowCardinality(String)),
  recorder_speed SimpleAggregateFunction(max, LowCardinality(String)),
  plate_color SimpleAggregateFunction(max, LowCardinality(String)),
  vehicle_type SimpleAggregateFunction(max, LowCardinality(String)),
  driver_name SimpleAggregateFunction(max, LowCardinality(String)),
  certification_id SimpleAggregateFunction(max, LowCardinality(String)),
  person_id SimpleAggregateFunction(max, LowCardinality(String)),
  person_name SimpleAggregateFunction(max, LowCardinality(String)),
  handle_time SimpleAggregateFunction(max, Int64),
  org_id SimpleAggregateFunction(max, LowCardinality(String)),
  org_name SimpleAggregateFunction(max, LowCardinality(String)),
  road_type SimpleAggregateFunction(max, Int32),
  dir SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  riskId SimpleAggregateFunction(max, LowCardinality(String)),
  remark SimpleAggregateFunction(max, LowCardinality(String)),
  person_org_name SimpleAggregateFunction(max, LowCardinality(String)),
  send_of_msg SimpleAggregateFunction(max, LowCardinality(String)),
  deal_of_msg SimpleAggregateFunction(max, LowCardinality(String)),
  oversee_time SimpleAggregateFunction(max, Int64),
  oversee_dead_time SimpleAggregateFunction(max, Int64),
  oversee_people SimpleAggregateFunction(max, LowCardinality(String)),
  response_time SimpleAggregateFunction(max, Int64),
  oversee_status SimpleAggregateFunction(max, Int32),
  oversee_type SimpleAggregateFunction(max, Int32),
  oversee_level SimpleAggregateFunction(max, Int32),
  handle_result SimpleAggregateFunction(max, Int32),
  oversee_result SimpleAggregateFunction(max, Int8)
 )
engine AggregatingMergeTree()
order by (monitor_id, alarm_start_time, alarm_type)
partition by toDate(alarm_start_time)
PRIMARY KEY(monitor_id, alarm_start_time, alarm_type);

