/* adas风险附件表 */
CREATE TABLE risk_media (
   id String,
   risk_time DateTime64 CODEC(DoubleDelta),
   media_id SimpleAggregateFunction(max, Int64),
   risk_id SimpleAggregateFunction(max, LowCardinality(String)),
   risk_event_id SimpleAggregateFunction(max, LowCardinality(String)),
   risk_number SimpleAggregateFunction(max, LowCardinality(String)),
   event_number SimpleAggregateFunction(max, LowCardinality(String)),
   vehicle_id SimpleAggregateFunction(max, LowCardinality(String)),
   visit_id SimpleAggregateFunction(max, LowCardinality(String)),
   type SimpleAggregateFunction(max, Int8),
   name SimpleAggregateFunction(max, LowCardinality(String)),
   url SimpleAggregateFunction(max, LowCardinality(String)),
   format_code SimpleAggregateFunction(max, Int32),
   event_code SimpleAggregateFunction(max, Int8),
   channel_id SimpleAggregateFunction(max, Int8),
   brand SimpleAggregateFunction(max, LowCardinality(String)),
   source SimpleAggregateFunction(max, Int8),
   event_id SimpleAggregateFunction(max, Int32),
   address SimpleAggregateFunction(max, LowCardinality(String)),
   risk_type SimpleAggregateFunction(max, LowCardinality(String)),
   create_time SimpleAggregateFunction(max, Int64),
   create_user SimpleAggregateFunction(max, LowCardinality(String)),
   protocol_type SimpleAggregateFunction(max, Int8),
   dealer SimpleAggregateFunction(max, LowCardinality(String)),
   result SimpleAggregateFunction(max, Int8),
   risk_level SimpleAggregateFunction(max, Int8),
   deal_status SimpleAggregateFunction(max, Int8),
   driver_name SimpleAggregateFunction(max, LowCardinality(String)),
   file_size SimpleAggregateFunction(max, Int64)
)
engine AggregatingMergeTree()
order by (id,risk_time)
partition by toDate(risk_time)
PRIMARY KEY(id,risk_time);

