tables.sql 833 B

12345678910111213141516171819202122
  1. create database if not exists otel_cold on cluster default;
  2. use otel_cold;
  3. create table if not exists otel_cold.sample_hit_trace_local on cluster default
  4. (
  5. trace_id String not null,
  6. timestamp bigint not null,
  7. INDEX idx_timestamp timestamp type minmax granularity 1
  8. )
  9. ENGINE = ReplicatedMergeTree('/clickhouse/otel_cold/tables/{shard}/sample_hit_trace_local', '{replica}')
  10. partition by (toDate(fromUnixTimestamp64Milli(timestamp)))
  11. ttl toDateTime(fromUnixTimestamp64Milli(timestamp)) + interval 24 hour
  12. order by (timestamp)
  13. settings index_granularity = 8192, ttl_only_drop_parts = 1;
  14. CREATE TABLE if not exists otel_cold.sample_hit_trace on cluster default
  15. (
  16. `trace_id` String,
  17. `timestamp` bigint
  18. )
  19. ENGINE = Distributed('default', 'otel_cold', 'sample_hit_trace_local', rand());