How to count the rows you've transformed

After some pain, here we go! How to log out the number of lines transfomed into your model.

{% macro log_order_items() %}

{%- call statement('count_order_items', fetch_result=True) -%}
    SELECT count(*) as count from {{ this }}
{%- endcall -%}

{%- set total_order_items = load_result('count_order_items') -%}

{% if execute %}
    {{ log(modules.datetime.datetime.now().strftime('%H:%M:%S') ~ ' | Number of rows transformed ' ~ total_order_items['data'][0][0] ~ ' rows into a table', True) }}
{% endif %}

select 1

{% endmacro %}