-- Analytical fact table: document_extractions
-- Partitioned by dt and model_version on MinIO

CREATE TABLE IF NOT EXISTS lakehouse.stonks.document_extractions (
    document_id       VARCHAR,
    ticker            VARCHAR,
    sentiment         VARCHAR,
    impact_score      DOUBLE,
    catalyst_type     VARCHAR,
    confidence        DOUBLE,
    novelty_score     DOUBLE,
    model_name        VARCHAR,
    prompt_version    VARCHAR,
    extraction_at     TIMESTAMP(6) WITH TIME ZONE,
    dt                DATE,
    model_version     VARCHAR
) WITH (
    format = 'PARQUET',
    partitioned_by = ARRAY['dt', 'model_version'],
    external_location = 's3a://stonks-lakehouse/warehouse/document_extractions/'
);
