-- Analytical fact table: company_events
-- Corporate actions, earnings, filings, and other issuer events.
-- Partitioned by dt (date) on MinIO.
-- Path: s3://stonks-lakehouse/warehouse/company_events/dt={yyyy-mm-dd}/part-*.parquet
-- Requirements: 2.3, 9.4, 9.5, 10.1
-- Design ref: Section 7 (lake.company_events)

CREATE TABLE IF NOT EXISTS lakehouse.stonks.company_events (
    event_id      VARCHAR,
    ticker        VARCHAR,
    event_type    VARCHAR,
    event_subtype VARCHAR,
    title         VARCHAR,
    description   VARCHAR,
    source        VARCHAR,
    source_url    VARCHAR,
    event_at      TIMESTAMP(6) WITH TIME ZONE,
    ingested_at   TIMESTAMP(6) WITH TIME ZONE,
    dt            DATE
) WITH (
    format = 'PARQUET',
    partitioned_by = ARRAY['dt'],
    external_location = 's3a://stonks-lakehouse/warehouse/company_events/'
);
