Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with mocking via macro #61

Open
JackWolverson opened this issue Jan 24, 2023 · 2 comments
Open

Help with mocking via macro #61

JackWolverson opened this issue Jan 24, 2023 · 2 comments

Comments

@JackWolverson
Copy link

JackWolverson commented Jan 24, 2023

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

@mjirv
Copy link
Owner

mjirv commented Mar 28, 2023

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...

@LeopoldGabelmann
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants