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


-- LOGIC
companies_rename AS (

    SELECT
        companies.id,
        companies.name,
        companies.reference                                                                         AS marking_id,
        companies.debtor                                                                            AS account_software_id,
        companies.type                                                                              AS company_type,
        companies.business_type,   
        companies.status,
        companies.deleted_at,
        companies.created_at,
        companies.updated_at,
        current_timestamp()                                                                         AS _dbt_ran_at

    FROM companies
),


-- FINAL
final__base_exchange__companies AS (

    SELECT
        id,
        name,
        marking_id,
        account_software_id,
        company_type,
        business_type,
        status,
        deleted_at,
        created_at,
        updated_at,
        _dbt_ran_at

    FROM companies_rename

) 

SELECT * FROM final__base_exchange__companies