dbt-datamocktool icon indicating copy to clipboard operation
dbt-datamocktool copied to clipboard

Help with mocking via macro

Open JackWolverson opened this issue 2 years ago • 2 comments

im trying to mock data using a macro following the example

{% macro expected_invoices() %}

(
    {% set records = [
        [1,"aaaaaaaa","type"]
    ] %}

    {% for record in records %}
        select {{ record[0] }} as sys_id, '{{ record[1] }}' as id , '{{ record[2] }}' as type
        {% if not loop.last %}
            union all
        {% endif %}
    {% endfor %}
) expected_invoices

{% endmacro %}

but am getting the error when running of Macro test_equality expected a Relation but received the value: 14:35:41 ( select 1 as sys_id, 'aaaaaaaa' as id, 'FAC' as type ) as expected_invoices

i have this set up in my .yml

      - dbt_datamocktool.unit_test:
          input_mapping:
            ref('table'): "{{ input_invoices() }}"
          expected_output: "{{ expected_invoices() }}"
          name: "expecting_type_of"
          description: "testing mocking data fro dbt unit testing"
          compare_columns:
           - sys_id
           - id
           - type

am i missing something else anywhere ? any help would be much appreciated dbt version 1.3 and im using trino

JackWolverson avatar Jan 24 '23 14:01 JackWolverson

Sorry for the delay here. Inputs can be macros but expected outputs have to be seed or models right now because the equality test expects a relation.

Let me see if there's a way around that...

mjirv avatar Mar 28 '23 14:03 mjirv

@mjirv do you mind if I pick this up? Can look into it

LeopoldGabelmann avatar Oct 10 '23 08:10 LeopoldGabelmann