This is probably a really daft question, but I am trying to follow the instructions at (Custom schemas | dbt Developer Hub) to be able to set custom schema so that the models in one folder go to a different schema (which I am happy to be target_custom in the normal way).
If I put in an individual model, the following code creates a table in default_openair (which is what I want):
{{ config(schema=‘openair’) }}
But I’d like to be able to do this on batch for a number of files in the folder (yet to be created). I’ve created a dbt_project.yml which looks like this:
-
The arrow points to the file I am testing - this keeps showing up in just my ‘target’ schema (which is ‘default’).
-
1 points to the project name - that was created by default, and when I try and change it causes an error.
-
2 shows what I’ve tried - but I also have tried it without the ‘my_new_project’ bit of code.
In-case its helpful the code from dbt_project.yml is here:
# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: 'my_new_project'
version: '1.0.0'
config-version: 2
# This setting configures which "profile" dbt uses for this project.
profile: 'default'
# These configurations specify where dbt should look for different types of files.
# The `source-paths` config, for example, states that models in this project can be
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
target-path: "target" # directory which will store compiled SQL files
clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_packages"
# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models
# In this example config, we tell dbt to build all models in the example/ directory
# as tables. These settings can be overridden in the individual model files
# using the `{{ config(...) }}` macro.
models:
my_new_project:
openair:
staging:
+schema: openair
my_new_project:
# Applies to all files under models/example/
example:
materialized: view
Apologies - I have done a search on the forum and couldn’t find the magic answer - but I’m sure I’m going to be kicking myself in a moment…
Thanks,
James