sqlmesh icon indicating copy to clipboard operation
sqlmesh copied to clipboard

Support dbt-native unit tests within dbt adaptor

Open calswbin opened this issue 4 months ago • 0 comments

dbt have extended their testing methodology to include unit tests, defined in YML, with static input data and an explicit target result.

unit_tests:
  - name: test_is_valid_email_address
    description: "Check my is_valid_email_address logic captures all known edge cases..."
    model: dim_customers
    given:
      - input: ref('stg_customers')
        rows:
          - {email: [email protected],    email_top_level_domain: example.com}
          - {email: [email protected],    email_top_level_domain: unknown.com}
          - {email: badgmail.com,        email_top_level_domain: gmail.com}
          - {email: missingdot@gmailcom, email_top_level_domain: gmail.com}
      - input: ref('top_level_email_domains')
        rows:
          - {tld: example.com}
          - {tld: gmail.com}
    expect:
      rows:
        - {email: [email protected],    is_valid_email_address: true}
        - {email: [email protected],    is_valid_email_address: false}
        - {email: badgmail.com,        is_valid_email_address: false}
        - {email: missingdot@gmailcom, is_valid_email_address: false}

Currently sqlmesh maps all dbt-defined tests as sqlmesh audits, and requires all unit tests to be written as sqlmesh tests.

calswbin avatar Sep 16 '25 09:09 calswbin