-- IMPORTS
WITH jobs AS (
    SELECT * FROM {{ source('src_exchange_mysql', 'jobs') }}
),


-- LOGIC
jobs_rename AS (

    SELECT
        jobs.id,
        jobs.queue,
        jobs.payload,
        jobs.attempts,
        TO_TIMESTAMP(jobs.reserved_at)                                                                  AS reserved_at, 
        TO_TIMESTAMP(jobs.available_at)                                                                 AS available_at,
        TO_TIMESTAMP(jobs.created_at)                                                                   AS created_at,
        current_timestamp()                                                                             AS _dbt_ran_at

    FROM jobs
),


-- FINAL
final__base_exchange__jobs AS (

    SELECT
        id,
        queue,
        payload,
        attempts,
        reserved_at,
        available_at,
        created_at,
        _dbt_ran_at

    FROM jobs_rename

) 

SELECT * FROM final__base_exchange__jobs