-- Analytical fact table: trade_orders
-- Partitioned by dt on MinIO

CREATE TABLE IF NOT EXISTS lakehouse.stonks.trade_orders (
    order_id          VARCHAR,
    ticker            VARCHAR,
    side              VARCHAR,
    order_type        VARCHAR,
    quantity          DOUBLE,
    limit_price       DOUBLE,
    status            VARCHAR,
    broker_account    VARCHAR,
    submitted_at      TIMESTAMP(6) WITH TIME ZONE,
    dt                DATE
) WITH (
    format = 'PARQUET',
    partitioned_by = ARRAY['dt'],
    external_location = 's3a://stonks-lakehouse/warehouse/trade_orders/'
);
