tlog.app/go/tlog@v0.23.1/ext/tlclick/schema.sql (about) 1 2 CREATE TABLE IF NOT EXISTS events ( 3 tlog String, 4 json String, 5 6 ts DateTime64(9, 'UTC'), 7 8 labels Array(String), 9 _labels Array(String), 10 _labels_hash UInt64 MATERIALIZED cityHash64(_labels), 11 12 _s UUID, -- MATERIALIZED toUUIDOrZero(visitParamExtractString(json, '_s')), 13 _p UUID, -- MATERIALIZED toUUIDOrZero(visitParamExtractString(json, '_p')), 14 15 _refs Map(String, UUID), 16 17 _k FixedString(1) MATERIALIZED visitParamExtractString(json, '_k'), 18 _m String MATERIALIZED visitParamExtractString(json, '_m'), 19 _l Int8 MATERIALIZED visitParamExtractInt(json, '_l'), 20 _e Int64 MATERIALIZED visitParamExtractInt(json, '_e'), 21 22 err String MATERIALIZED visitParamExtractString(json, 'err'), 23 24 kvs Map(String, String) MATERIALIZED mapFromArrays( 25 (arrayFilter( 26 k -> k NOT IN ('_s', '_p', '_t', '_c', '_k', '_m', '_l', '_e', 'err'), 27 JSONExtractKeys(json) 28 ) AS kv_keys), 29 arrayMap(k -> JSONExtractRaw(json, k), kv_keys) 30 ), 31 32 minute DateTime ALIAS toStartOfMinute(ts), 33 hour DateTime ALIAS toStartOfHour(ts), 34 day Date MATERIALIZED toStartOfDay(ts), 35 week Date ALIAS toStartOfWeek(ts), 36 month Date ALIAS toStartOfMonth(ts), 37 year Date ALIAS toStartOfYear(ts), 38 ) 39 ENGINE MergeTree 40 ORDER BY ts 41 PARTITION BY day 42 ; 43 44 CREATE TABLE IF NOT EXISTS spans ( 45 span UUID, 46 47 parent SimpleAggregateFunction(max, UUID), 48 refs AggregateFunction(groupUniqArray, Array(UUID)), 49 50 start DateTime64(9, 'UTC'), 51 end DateTime64(9, 'UTC'), 52 53 elapsed Int64, 54 finish_err String, 55 56 day DateTime, 57 ) 58 ENGINE AggregatingMergeTree 59 ORDER BY span 60 PARTITION BY day 61 ; 62 63 CREATE TABLE IF NOT EXISTS labels ( 64 label String, 65 span UUID, 66 67 day DateTime, 68 ) 69 ENGINE AggregatingMergeTree 70 ORDER BY (label, span) 71 PARTITION BY day 72 ;