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

in-model configs, show config options in prologue #95

Closed

Conversation

drewbanin
Copy link
Contributor

@drewbanin drewbanin commented Aug 9, 2016

With this branch, configurations can be specified directly inside of models. The configs work exactly the same as configs inside of the dbt_project.yml file.

An in-model-config looks like this:

{{ config(materialized="incremental", sql_where="id > (select max(id) from {{this}})") }}
-- or you can use python dict syntax:
{{ config({"materialized:" "incremental", "sql_where" : "id > (select max(id) from {{this}})"}) }}
-- you can only call config() once in a model, so don't do both!

select * from public.users

The config options are injected into the existing configs (more on this below) and the config(...) function call is replaced with a SQL comment containing the injected config options, eg:

-- Config specified in model: {'materialized': 'incremental', 'sql_where': 'id > (select max(id) from {{this}})'}

select * from public.users

If the model is in your package, then config resolution works in the following order (later configs overwrite previous configs):

  1. model-defaults (dbt_project.yml)
  2. in-model configs (your_model.sql)
  3. models (dbt_project.yml)

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

Successfully merging this pull request may close these issues.

1 participant