/* adas风险事件表 */
CREATE TABLE risk_event (
   id String,
   warn_time DateTime64 CODEC(DoubleDelta),
   number SimpleAggregateFunction(max, LowCardinality(String)),
   event_id SimpleAggregateFunction(max, LowCardinality(String)),
   vehicle_id SimpleAggregateFunction(max, LowCardinality(String)),
   brand SimpleAggregateFunction(max, LowCardinality(String)),
   time SimpleAggregateFunction(max, Int64),
   risk_id SimpleAggregateFunction(max, LowCardinality(String)),
   risk_number SimpleAggregateFunction(max, LowCardinality(String)),
   media_id SimpleAggregateFunction(max, LowCardinality(String)),
   media_name SimpleAggregateFunction(max, LowCardinality(String)),
   media_url SimpleAggregateFunction(max, LowCardinality(String)),
   warn_id SimpleAggregateFunction(max, Int32),
   sensor_id SimpleAggregateFunction(max, Int8),
   status SimpleAggregateFunction(max, Int8),
   type SimpleAggregateFunction(max, Int8),
   level SimpleAggregateFunction(max, Int8),
   sign_type SimpleAggregateFunction(max, Int8),
   sign_data SimpleAggregateFunction(max, Int32),
   fatigue_level SimpleAggregateFunction(max, Int32),
   speed_limit SimpleAggregateFunction(max, Int32),
   front_speed SimpleAggregateFunction(max, Float64),
   front_distance SimpleAggregateFunction(max, Float64),
   deviation SimpleAggregateFunction(max, Int8),
   speed SimpleAggregateFunction(max, Float64),
   altitude SimpleAggregateFunction(max, Float64),
   latitude SimpleAggregateFunction(max, Float64),
   longitude SimpleAggregateFunction(max, Float64),
   vehicle_status SimpleAggregateFunction(max, Int32),
   keep SimpleAggregateFunction(max, Int32),
   media_total SimpleAggregateFunction(max, Int32),
   create_time SimpleAggregateFunction(max, Int64),
   create_user SimpleAggregateFunction(max, LowCardinality(String)),
   visit_times SimpleAggregateFunction(max, Int8),
   result SimpleAggregateFunction(max, Int8),
   risk_type SimpleAggregateFunction(max, LowCardinality(String)),
   driver_id SimpleAggregateFunction(max, LowCardinality(String)),
   dealer SimpleAggregateFunction(max, LowCardinality(String)),
   driver_name SimpleAggregateFunction(max, LowCardinality(String)),
   risk_level SimpleAggregateFunction(max, Int8),
   address SimpleAggregateFunction(max, LowCardinality(String)),
   risk_speed SimpleAggregateFunction(max, Float64),
   job SimpleAggregateFunction(max, LowCardinality(String)),
   deal_status SimpleAggregateFunction(max, Int8),
   risk_time SimpleAggregateFunction(max, Int64),
   deal_time SimpleAggregateFunction(max, Int64),
   file_time SimpleAggregateFunction(max, Int64),
   video_flag SimpleAggregateFunction(max, Int8),
   pic_flag SimpleAggregateFunction(max, Int8),
   weather SimpleAggregateFunction(max, LowCardinality(String)),
   oversee_status SimpleAggregateFunction(max, Int8),
   transportation SimpleAggregateFunction(max, Int8),
   multimedia_number SimpleAggregateFunction(max, Int32),
   sequence_number SimpleAggregateFunction(max, Int32),
   attachment_status SimpleAggregateFunction(max, Int8),
   media_info SimpleAggregateFunction(max, LowCardinality(String)),
   plateform_id SimpleAggregateFunction(max, LowCardinality(String)),
   msg_sn SimpleAggregateFunction(max, LowCardinality(String)),
   original_longitude SimpleAggregateFunction(max, Float64),
   original_latitude SimpleAggregateFunction(max, Float64),
   driver_no SimpleAggregateFunction(max, LowCardinality(String)),
   direction SimpleAggregateFunction(max, Float64),
   grapher_speed SimpleAggregateFunction(max, Float64),
   info_content SimpleAggregateFunction(max, LowCardinality(String)),
   handle_type SimpleAggregateFunction(max, LowCardinality(String)),
   remark SimpleAggregateFunction(max, LowCardinality(String)),
   plate_color SimpleAggregateFunction(max, Int8),
   road_type SimpleAggregateFunction(max, Int32),
   road_limit_speed SimpleAggregateFunction(max, Float64),
   alarm_id SimpleAggregateFunction(max, LowCardinality(String)),
   drv_line_id SimpleAggregateFunction(max, Int32),
   protocol_type SimpleAggregateFunction(max, Int32),
   is_remind_driver SimpleAggregateFunction(max, Int32),
   limit_speed SimpleAggregateFunction(max, Int32),
   actual_load SimpleAggregateFunction(max, Int32),
   limited_load SimpleAggregateFunction(max, Int32)
)
engine AggregatingMergeTree()
order by (id,warn_time)
partition by toDate(warn_time)
PRIMARY KEY(id,warn_time);
