-- Analytical fact table: documents
-- Partitioned by dt and source_type on MinIO
-- Path: s3://stonks-lakehouse/warehouse/documents/dt={yyyy-mm-dd}/source_type={type}/part-*.parquet

CREATE TABLE IF NOT EXISTS lakehouse.stonks.documents (
    document_id   VARCHAR,
    document_type VARCHAR,
    source_type   VARCHAR,
    ticker        VARCHAR,
    publisher     VARCHAR,
    title         VARCHAR,
    published_at  TIMESTAMP(6) WITH TIME ZONE,
    content_hash  VARCHAR,
    confidence    DOUBLE,
    dt            DATE
) WITH (
    format = 'PARQUET',
    partitioned_by = ARRAY['dt'],
    external_location = 's3a://stonks-lakehouse/warehouse/documents/'
);
