Skip to content

Instantly share code, notes, and snippets.

@jeremyyeo
Last active September 28, 2022 09:49
Show Gist options
  • Save jeremyyeo/1aeca767e2a4f157b07955d58f8078f7 to your computer and use it in GitHub Desktop.
Save jeremyyeo/1aeca767e2a4f157b07955d58f8078f7 to your computer and use it in GitHub Desktop.
The difference between `--select` and `--selector` arguments in dbt commands #dbt

The difference between --select and --selector in dbt

Assume we have a toy project with 1 model, 1 snapshot and 1 selector.

-- models/foo.sql
{{ config(tags='my_tag') }}

select 1 as id

-- snapshots/bar.sql
{% snapshot bar %}

{{
    config(
      target_schema='analytics',
      unique_key='id',
      strategy='check',
      check_cols='all',
      tags='my_tag'
    )
}}

select 1 as id

{% endsnapshot %}
# selectors.yml

selectors:
  - name: only_my_tag
    definition:
      tag: my_tag

Basics

image

--selector uses the selectors.yml file.

--select does not.

The run command

image

The snapshot command

image

The build command

image

@mirnawong1
Copy link

this is awesome, thank you for explaining @jeremyyeo !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment