/* 位置表 */
create table gps
(
  ts DateTime64 CODEC(DoubleDelta),
  monitor_id String,
  monitor_name SimpleAggregateFunction(max, LowCardinality(String)),
  group_name SimpleAggregateFunction(max, LowCardinality(String)),
  org_id SimpleAggregateFunction(max, LowCardinality(String)),
  city SimpleAggregateFunction(max, LowCardinality(String)),
  province SimpleAggregateFunction(max, LowCardinality(String)),
  vehicle_type SimpleAggregateFunction(max, LowCardinality(String)),
  status SimpleAggregateFunction(max, Int64),
  alarm SimpleAggregateFunction(max, Int64),
  lat SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  lon SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  alt SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  dir SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  original_lon SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  original_lat SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  speed SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  mileage SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  address SimpleAggregateFunction(max, LowCardinality(String)),
  invalid SimpleAggregateFunction(max, Int8),
  location_status SimpleAggregateFunction(max, Int8),
  org_name SimpleAggregateFunction(max, LowCardinality(String)),
  professionals_name SimpleAggregateFunction(max, LowCardinality(String)),
  device_number SimpleAggregateFunction(max, LowCardinality(String)),
  sim_card SimpleAggregateFunction(max, LowCardinality(String)),
  recorder_speed SimpleAggregateFunction(max, Float64) CODEC(Gorilla),
  temp SimpleAggregateFunction(max, LowCardinality(String)),
  fuel_type SimpleAggregateFunction(max, LowCardinality(String)),
  air_condition_status SimpleAggregateFunction(max, LowCardinality(String)),
  upload_time SimpleAggregateFunction(max, Int64),
  battery_electricity SimpleAggregateFunction(max, Int32),
  battery_voltage SimpleAggregateFunction(max, Int32),
  signal_strength SimpleAggregateFunction(max, Int32),
  terminal_version SimpleAggregateFunction(max, LowCardinality(String)),
  location_type SimpleAggregateFunction(max, Int32),
  air_comp_status SimpleAggregateFunction(max, Int32),
  protocol_type SimpleAggregateFunction(max, LowCardinality(String)),
  user_code SimpleAggregateFunction(max, LowCardinality(String)),
  alarm_sign SimpleAggregateFunction(max, Int32),
  wifi_info SimpleAggregateFunction(max, LowCardinality(String)),
  station_info SimpleAggregateFunction(max, LowCardinality(String)),
  monitor_type SimpleAggregateFunction(max, Int8),
  plate_color SimpleAggregateFunction(max, LowCardinality(String)),
  scheduled_status SimpleAggregateFunction(max, LowCardinality(String)),
  work_status SimpleAggregateFunction(max, LowCardinality(String)),
  reissue SimpleAggregateFunction(max, Int8),
  metrics SimpleAggregateFunction(max, Array(String)),
  metrics_values SimpleAggregateFunction(max, Array(String))
)
engine AggregatingMergeTree()
order by (monitor_id, ts)
partition by toDate(ts)
PRIMARY KEY(monitor_id, ts);

