ALTER TABLE hits ADD COLUMN IF NOT EXISTS region VARCHAR;
ALTER TABLE hits ADD COLUMN IF NOT EXISTS city VARCHAR;
ALTER TABLE hits ADD COLUMN IF NOT EXISTS provider VARCHAR;
ALTER TABLE hits ADD COLUMN IF NOT EXISTS asn INTEGER;
ALTER TABLE hits ADD COLUMN IF NOT EXISTS asn_org VARCHAR;

CREATE OR REPLACE MACRO hk_asn(asn, asn_org) AS (
    CASE
        WHEN asn IS NULL THEN '(Unknown)'
        WHEN NULLIF(TRIM(asn_org), '') IS NULL THEN 'AS' || CAST(asn AS VARCHAR)
        ELSE 'AS' || CAST(asn AS VARCHAR) || ' ' || TRIM(asn_org)
    END
);
