Workaround for arrays not supported in unit test expected output

I’m trying to write a unit test that has an array as an expected value.

unit_tests:
    - name: my_unit_test
      model: my_model
      given:
        - input: ref('my_source')
          rows:
            - {id: '1', data: '{"array": [{"prop1": "some value", "prop2": "another value"}, {"prop1": "value", "prop2": "value 2"}]}'}
            
      expect:
        rows:
            - {id: '1', array: [{"prop1": "some value", "prop2": "another value"}, {"prop1": "value", "prop2": "value 2"}] }

This is giving me a syntax error because according to the documentation here Platform-specific data types | dbt Developer Hub, “Currently, the array is not supported.”

I tried enclosing the array with quotes but that also gave an error.

Is there any known workaround for this issue?

Not sure how to solve it, but I would try using the SQL format Supported data formats for unit tests | dbt Developer Hub

And then write your array like you would write in your platform

Thanks, that helped me!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.