Denormalized view of Hubspot’s owners data. This view can be used together with other Hubspot views
-- CREATE VIEW hubspot_owners_consolidated AS
SELECT ownerid AS owner_id
, type
, firstname AS first_name
, lastname AS last_name
, email
, TIMESTAMP 'epoch' + createdat / 1000 * interval '1 second' AS created_date
, TIMESTAMP 'epoch' + updatedat / 1000 * interval '1 second' AS updated_date
FROM hubspot_owners
WHERE case when isactive = 1 then TRUE when isactive = 0 then FALSE else isactive::bigint::boolean end IS TRUE;