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

Code-based mechanism for configuring models #594

Closed
drewbanin opened this issue Nov 10, 2017 · 1 comment
Closed

Code-based mechanism for configuring models #594

drewbanin opened this issue Nov 10, 2017 · 1 comment

Comments

@drewbanin
Copy link
Contributor

drewbanin commented Nov 10, 2017

dbt should provide a mechanism for configuring sets of models through code. This configuration/selection should happen in Python, as it's a much more capable and flexible mechanism for describing business logic than Jinja.

A potential interface for this might look like:

models.select(package='snowplow', materialized='incremental').onComplete([redshift.vacuum, redshift.analyze) }}

This snippet would be responsible for adding post-hooks to all incremental models in the Snowplow package.

Some more examples:

# Turn off all snowplow models
models.select(package="snowplow").config(enabled=False) }}

# Enable the `snowplow_page_views` model in the `snowplow` package
models.select(fqn="snowplow.snowplow_page_views").config(enabled=True) }}

# Configure all `view` models in the Snowplow package to be `ephemeral`
models.select(package="snowplow", materialized"view").config(materialized='ephemeral') }}

# Drops all models in the snowplow package where the set of `tags` includes `temporary`
models.select(package="snowplow", hasTags=["temporary"]).onRunEnd(dbt.drop_relation) }}

Altogether, this would be used in a script like:

#!/usr/bin/env python

import dbt

project = dbt.load_project()
models = project.models()

models_to_run = models.select(package="snowplow", children=True, parents=True)
results = models_to_run.run()

This is sort of a vignette of what model selection/configuration in code could look like. Alternative proposals are welcomed!

@drewbanin
Copy link
Contributor Author

See #1842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant