[v2 Bug] Overridden `create_schema` not respected
Author: jeremyyeoCreated Sep 17, 2026Updated Sep 17, 2026
Labelstype:bugstatus:triagearea:adaptersengine:v2triagebugsnowflakev2
Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?
- I believe this is a new bug in dbt v2.x
- I have searched the existing issues and could not find a duplicate
Current Behavior
A common pattern in v1 is to override the macro that creates schemas when they don't exist (create_schema). Users do this for various reasons - e.g. I want to block my users from doing so, or they want to do that with special DDL from the one out of the box.
In v2, the overridden macro is ignored.
Expected Behavior
Do as per v1.
Steps To Reproduce
# dbt_project.yml
name: dbt_basic_5
profile: sf
models:
dbt_basic_5:
+materialized: table
+schema: a_brand_new_schemav1
-- macros/override.sql
{% macro create_schema(relation) %}
{{ log(">>> Custom create_schema override for " ~ relation.without_identifier(), info=True) }}
{%- call statement('create_schema') -%}
select 'not allowed to create schemas' as can_you
{% endcall %}
{% endmacro %}
-- models/foo.sql
select 1 c$ dbt --debug run
...
15:27:11 Concurrency: 4 threads (target='dev')
15:27:11
15:27:11 Acquiring new snowflake connection 'master'
15:27:11 Acquiring new snowflake connection 'list_db'
15:27:11 Using snowflake connection "list_db"
15:27:11 On list_db: show terse schemas in database db
limit 10000
/* {"app": "dbt", "dbt_version": "1.11.11", "profile_name": "sf", "target_name": "dev", "connection_name": "list_db"} */
15:27:11 Opening a new connection, currently in state init
15:27:12 SQL status: SUCCESS 143 in 0.626 seconds
15:27:12 Re-using an available connection from the pool (formerly list_db, now create_db_dbt_jyeo_a_brand_new_schema)
15:27:12 Creating schema "database: "db"
schema: "dbt_jyeo_a_brand_new_schema"
"
15:27:12 >>> Custom create_schema override for db.dbt_jyeo_a_brand_new_schema
15:27:12 Using snowflake connection "create_db_dbt_jyeo_a_brand_new_schema"
15:27:12 On create_db_dbt_jyeo_a_brand_new_schema: select 'not allowed to create schemas' as can_you
/* {"app": "dbt", "dbt_version": "1.11.11", "profile_name": "sf", "target_name": "dev", "connection_name": "create_db_dbt_jyeo_a_brand_new_schema"} */
15:27:12 SQL status: SUCCESS 1 in 0.077 seconds
15:27:12 Re-using an available connection from the pool (formerly create_db_dbt_jyeo_a_brand_new_schema, now list_db_dbt_jyeo_a_brand_new_schema)
15:27:12 Acquiring new snowflake connection 'list_db_dbt_jyeo'
15:27:12 Using snowflake connection "list_db_dbt_jyeo_a_brand_new_schema"
15:27:12 Using snowflake connection "list_db_dbt_jyeo"
15:27:12 On list_db_dbt_jyeo_a_brand_new_schema: show objects in db.dbt_jyeo_a_brand_new_schema
limit 10000
/* {"app": "dbt", "dbt_version": "1.11.11", "profile_name": "sf", "target_name": "dev", "connection_name": "list_db_dbt_jyeo_a_brand_new_schema"} */;
15:27:12 On list_db_dbt_jyeo: show objects in db.dbt_jyeo
limit 10000
/* {"app": "dbt", "dbt_version": "1.11.11", "profile_name": "sf", "target_name": "dev", "connection_name": "list_db_dbt_jyeo"} */;
15:27:12 Opening a new connection, currently in state init
15:27:12 Snowflake adapter: Snowflake query id: 01c7223f-090d-a710-000d-37836dd2f6ba
15:27:12 Snowflake adapter: Snowflake error: 002043 (02000): SQL compilation error:
Object does not exist, or operation cannot be performed.
15:27:12 Snowflake adapter: Error running SQL: macro list_relations_without_caching
15:27:12 Snowflake adapter: Rolling back transaction.
15:27:12 SQL status: SUCCESS 43 in 0.579 seconds
15:27:12 Sending event: {'category': 'dbt', 'action': 'runnable_timing', 'label': '64641730-da67-4e4f-ad54-426c21360f19', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x119ecf380>]}
15:27:12 Began running node model.dbt_basic_5.foo
15:27:12 1 of 1 START sql table model dbt_jyeo_a_brand_new_schema.foo ................... [RUN]
...
15:27:13 On model.dbt_basic_5.foo: create or replace transient table db.dbt_jyeo_a_brand_new_schema.foo
as (select 1 c
)
/* {"app": "dbt", "dbt_version": "1.11.11", "profile_name": "sf", "target_name": "dev", "node_id": "model.dbt_basic_5.foo"} */;
15:27:13 Snowflake adapter: Snowflake query id: 01c7223f-090d-a6ab-000d-37836dd34032
15:27:13 Snowflake adapter: Snowflake error: 002003 (02000): SQL compilation error:
Schema 'DB.DBT_JYEO_A_BRAND_NEW_SCHEMA' does not exist or not authorized.
15:27:13 Database Error in model foo (models/foo.sql)
002003 (02000): SQL compilation error:
Schema 'DB.DBT_JYEO_A_BRAND_NEW_SCHEMA' does not exist or not authorized.
compiled code at target/run/dbt_basic_5/models/foo.sql
15:27:13 Sending event: {'category': 'dbt', 'action': 'run_model', 'label': '64641730-da67-4e4f-ad54-426c21360f19', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x11a7bce60>]}
15:27:13 1 of 1 ERROR creating sql table model dbt_jyeo_a_brand_new_schema.foo .......... [ERROR in 0.14s]
...^ create_schema macro override resulted in the non existent schema to not be created and model not to be built - all expected.
v2
$ dbtf run --log-level debug
dbt 2.0.4
Loading profiles.yml
Started loading packages
Loaded [ 0.00s] packages
dbt State service disabled by configuration; executing normally
Snowflake driver resolved: snowflake 0.21.0.dev+dbt0.21.18
create_debug_span(...).entered() took 147.084µs
stmt.execute() (submit+wait_for_completion, returns reader) took 191.346917ms
reader.schema() took 709ns
batch-consume loop (for res in reader) took 1.235833ms
do_execute(conn) (closure: stmt.execute + schema + batch loop) took 193.811ms
concat_batches + normalize_result_column_names took 277.042µs
record_current_span_status_from_attrs took 51.416µs
Query executed on node unknown:
show terse schemas in database db
limit 10000
/* {"app": "dbt", "connection_name": "", "dbt_version": "2.0.0", "profile_name": "sf", "target_name": "dev"} */
drop(query_span_guard) (span exit/export) took 53.625µs
create_debug_span(...).entered() took 31µs
stmt.execute() (submit+wait_for_completion, returns reader) took 215.920542ms
reader.schema() took 416ns
do_execute(conn) (closure: stmt.execute + schema + batch loop) took 217.936167ms
concat_batches + normalize_result_column_names took 14.25µs
record_current_span_status_from_attrs took 4.167µs
Query executed on node unknown:
create schema if not exists db.dbt_jyeo_a_brand_new_schema
/* {"app": "dbt", "connection_name": "", "dbt_version": "2.0.0", "profile_name": "sf", "target_name": "dev"} */
drop(query_span_guard) (span exit/export) took 40.708µs
Started rendering model dbt_jyeo_a_brand_new_schema.foo
Finished rendering [ 0.00s] model dbt_jyeo_a_brand_new_schema.foo [success]
Started analyzing model dbt_jyeo_a_brand_new_schema.foo
Finished analyzing [ 0.01s] model dbt_jyeo_a_brand_new_schema.foo [success]
Started running model dbt_jyeo_a_brand_new_schema.foo
create_debug_span(...).entered() took 13.583µs
stmt.execute() (submit+wait_for_completion, returns reader) took 153.820209ms
reader.schema() took 375ns
batch-consume loop (for res in reader) took 1.107334ms
do_execute(conn) (closure: stmt.execute + schema + batch loop) took 156.530167ms
concat_batches + normalize_result_column_names took 74.583µs
record_current_span_status_from_attrs took 4.791µs
Query executed on node model.dbt_basic_5.foo:
SHOW OBJECTS IN SCHEMA "DB"."DBT_JYEO_A_BRAND_NEW_SCHEMA" LIMIT 10000
drop(query_span_guard) (span exit/export) took 63µs
Writing runtime sql for node "model.dbt_basic_5.foo"
create_debug_span(...).entered() took 19.084µs
stmt.execute() (submit+wait_for_completion, returns reader) took 1.072657834s
reader.schema() took 458ns
do_execute(conn) (closure: stmt.execute + schema + batch loop) took 1.074700959s
concat_batches + normalize_result_column_names took 17.417µs
record_current_span_status_from_attrs took 5.125µs
Query executed on node model.dbt_basic_5.foo:
create or replace transient table db.dbt_jyeo_a_brand_new_schema.foo
as (select 1 c
)
/* {"app": "dbt", "dbt_version": "2.0.0", "node_id": "model.dbt_basic_5.foo", "profile_name": "sf", "target_name": "dev"} */
drop(query_span_guard) (span exit/export) took 79.042µs
Finished running [ 1.24s] model dbt_jyeo_a_brand_new_schema.foo [success]
Succeeded model dbt_jyeo_a_brand_new_schema.foo (table) [1 of 1 in 1.25s]
======================================================================================================================================================== Execution Summary ========================================================================================================================================================
Finished 'run' successfully for target 'dev' [9.5s]
Processed: 1 model
Summary: 1 total | 1 success^ Override is skipped - schema is created - and model is created - unexpected.
Relevant log output
Environment
- OS: macOS
- CPU: ARM
- dbt distribution and version: (`dbt --version`)
2.0.4Which database adapter are you using?
snowflake
Is this a discrepancy vs. dbt 1.x?
- Yes — this works in dbt 1.x but not in dbt v2.x
Additional Context
A workaround is to actually use the default namespace:
{% macro default__create_schema(relation) %}
{{ log(">>> Custom create_schema override for " ~ relation.without_identifier(), info=True) }}
{%- call statement('create_schema') -%}
select 'not allowed to create schemas' as can_you
{% endcall %}
{% endmacro %}$ dbtf run --log-level debug
dbt 2.0.4
Loading profiles.yml
Started loading packages
Loaded [ 0.00s] packages
dbt State service disabled by configuration; executing normally
Snowflake driver resolved: snowflake 0.21.0.dev+dbt0.21.18
create_debug_span(...).entered() took 127.834µs
stmt.execute() (submit+wait_for_completion, returns reader) took 241.023417ms
reader.schema() took 292ns
batch-consume loop (for res in reader) took 1.118167ms
do_execute(conn) (closure: stmt.execute + schema + batch loop) took 243.351458ms
concat_batches + normalize_result_column_names took 339.875µs
record_current_span_status_from_attrs took 44.875µs
Query executed on node unknown:
show terse schemas in database db
limit 10000
/* {"app": "dbt", "connection_name": "", "dbt_version": "2.0.0", "profile_name": "sf", "target_name": "dev"} */
drop(query_span_guard) (span exit/export) took 52.459µs
>>> Custom create_schema override for db.dbt_jyeo_a_brand_new_schema_2
create_debug_span(...).entered() took 19.417µs
stmt.execute() (submit+wait_for_completion, returns reader) took 175.242584ms
reader.schema() took 417ns
do_execute(conn) (closure: stmt.execute + schema + batch loop) took 178.83225ms
concat_batches + normalize_result_column_names took 26.125µs
record_current_span_status_from_attrs took 3.667µs
Query executed on node unknown:
select 'not allowed to create schemas' as can_you
/* {"app": "dbt", "connection_name": "", "dbt_version": "2.0.0", "profile_name": "sf", "target_name": "dev"} */
drop(query_span_guard) (span exit/export) took 47.791µs
Started rendering model dbt_jyeo_a_brand_new_schema_2.foo
Finished rendering [ 0.00s] model dbt_jyeo_a_brand_new_schema_2.foo [success]
Started analyzing model dbt_jyeo_a_brand_new_schema_2.foo
Finished analyzing [ 0.01s] model dbt_jyeo_a_brand_new_schema_2.foo [success]
Started running model dbt_jyeo_a_brand_new_schema_2.foo
create_debug_span(...).entered() took 10.834µs
Query executed on node model.dbt_basic_5.foo:
SHOW OBJECTS IN SCHEMA "DB"."DBT_JYEO_A_BRAND_NEW_SCHEMA_2" LIMIT 10000
create_debug_span(...).entered() took 24.541µs
Query executed on node model.dbt_basic_5.foo:
show objects like 'FOO' in schema db.dbt_jyeo_a_brand_new_schema_2
/* {"app": "dbt", "dbt_version": "2.0.0", "node_id": "model.dbt_basic_5.foo", "profile_name": "sf", "target_name": "dev"} */
Writing runtime sql for node "model.dbt_basic_5.foo"
create_debug_span(...).entered() took 32.5µs
Query executed on node model.dbt_basic_5.foo:
create or replace transient table db.dbt_jyeo_a_brand_new_schema_2.foo
as (select 1 c
)
/* {"app": "dbt", "dbt_version": "2.0.0", "node_id": "model.dbt_basic_5.foo", "profile_name": "sf", "target_name": "dev"} */
Finished running [ 2.39s] model dbt_jyeo_a_brand_new_schema_2.foo [error]
Failed model dbt_jyeo_a_brand_new_schema_2.foo (table) [1 of 1 in 2.40s]
======================================================================================================================================================= Errors and Warnings =======================================================================================================================================================
[error] [DbDriverFailed (dbt1308)]: Database Error in model foo (target/run/dbt_basic_5/models/foo.sql)
[Snowflake] 002003 (02000): SQL compilation error:
Schema 'DB.DBT_JYEO_A_BRAND_NEW_SCHEMA_2' does not exist or not authorized.
(in run/dbt_basic_5/models/foo.sql)
======================================================================================================================================================== Execution Summary ========================================================================================================================================================
Finished 'run' with 1 error for target 'dev' [7.2s]
Processed: 1 model
Summary: 1 total | 1 errorThough this would require a "behaviour/code change" from the users perspective.
Source: dbt-labs/dbt-core