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

dbt should only create schemas for models that are being run #1239

Closed
drewbanin opened this issue Jan 14, 2019 · 1 comment
Closed

dbt should only create schemas for models that are being run #1239

drewbanin opened this issue Jan 14, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@drewbanin
Copy link
Contributor

Issue

Issue description

dbt creates all of the schemas for models in a project, even if only a subset of the models have been selected with --models. Instead, dbt should only create the schemas for models which are invoked in a given run.

Results

dbt created every custom schema defined in a dbt project, even though I only selected one model with --models.

System information

dbt version: 0.13.0-a1
python version: 3.7.2
python path: /Users/drew/fishtown/dbt/env/bin/python3
os info: Darwin-18.2.0-x86_64-i386-64bit

Note: This affects versions before 0.13.0-a1, and appears to affect at least 0.12.1 and 0.12.2 (but possibly older versions too)

Steps to reproduce

  1. drop all of the schemas in your test database
  2. create the following models
-- models/model_1.sql

{{ config(schema='schema_1') }}

select 1 as id
-- models/model_2.sql

{{ config(schema='schema_2') }}

select 1 as id
-- models/model_3.sql

{{ config(schema='schema_3') }}

select 1 as id
  1. Invoke only a single model:
dbt run --model model_1
  1. Observe that schemas schema_1, schema_2, and schema_3 have been created
@drewbanin drewbanin added the bug Something isn't working label Jan 14, 2019
@drewbanin drewbanin added this to the Stephen Girard milestone Jan 14, 2019
@clausherther
Copy link
Contributor

We create a few models for specific purposes in separate Snowflake database (call it other_db) from the rest of the analytical data warehouse. However, we manage this from the same dbt repo we use for the DW to reuse code and base models.
When we run a job for just these models (--target other_db), it creates all the schemas in the other_db database, not just the one we need for these particular models.

beckjake added a commit that referenced this issue Jan 28, 2019
…ed-schemas

Only create schemas for selected nodes (#1239)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants