Search code examples
testinggoogle-bigquerydbt

DBT testing for the source tables


I have a sources.yml which consists of all the source table that I need for the dbt.

version: 2
sources:
    - name: external
    schema: external_table
    tables:
      - name: event
      - name: mapping_table

I want to write dbt testing in tests_config.yml for these two tables, is it possible to do it? Right now I have these in the tests_config.yml. However, when I try to run dbt test --select source:* it says nothing to do

version: 2

models:
  - name: event
    description:
    tests: 
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - Event
            - State
            - financial_week_no
            - financial_year

Really appreciate the help! Thank you!


Solution

  • As commented by @Aleix CC, to resolve the issue, you need to place your tests in source.yml, then dbt will run these tests with dbt test --select source:*

    Posting the answer as community wiki for the benefit of the community that might encounter this use case in the future. Feel free to edit this answer for additional information.