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

CREATE TABLE IF NOT EXISTS lakehouse.stonks.positions_daily (
    ticker            VARCHAR,
    quantity          DOUBLE,
    avg_entry_price   DOUBLE,
    close_price       DOUBLE,
    unrealized_pnl    DOUBLE,
    broker_account    VARCHAR,
    snapshot_at       TIMESTAMP(6) WITH TIME ZONE,
    dt                DATE
) WITH (
    format = 'PARQUET',
    partitioned_by = ARRAY['dt'],
    external_location = 's3a://stonks-lakehouse/warehouse/positions_daily/'
);
