CREATE TABLE IF NOT EXISTS traderepublic.quotes
(
    isin String,
    minute_start DateTime,
    last_record_timestamp AggregateFunction(max, DateTime),
    first_value AggregateFunction(argMin, Int64, DateTime),
    last_value AggregateFunction(argMax, Int64, DateTime),
    min_value AggregateFunction(min, Int64),
    max_value AggregateFunction(max, Int64)
) ENGINE = AggregatingMergeTree()
PARTITION BY isin
ORDER BY (isin, minute_start);

CREATE TABLE IF NOT EXISTS traderepublic.symbols
(
    isin String,
    description String,
    status Int8,
    added_on DateTime
) ENGINE = CollapsingMergeTree(status)
PARTITION BY isin
ORDER BY (isin, added_on)
