-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Source quoting ignores global configuration (#10905)
- Loading branch information
1 parent
d07bfda
commit 316ecfc
Showing
3 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Restore source quoting behaviour when quoting config provided in dbt_project.yml | ||
time: 2024-10-23T15:20:54.766893-04:00 | ||
custom: | ||
Author: michelleark | ||
Issue: "10892" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/functional/relation_quoting/test_relation_quoting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import read_file, run_dbt | ||
|
||
_SOURCES_YML = """ | ||
sources: | ||
- name: source_name | ||
database: source_database | ||
schema: source_schema | ||
tables: | ||
- name: customers | ||
""" | ||
|
||
|
||
class TestSourceQuotingGlobalConfigs: | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
# Postgres quoting configs are True by default -- turn them all to False to show they are not respected during source rendering | ||
return { | ||
"quoting": { | ||
"database": False, | ||
"schema": False, | ||
"identifier": False, | ||
}, | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"sources.yml": _SOURCES_YML, | ||
"model.sql": "select * from {{ source('source_name', 'customers') }}", | ||
} | ||
|
||
def test_sources_ignore_global_quoting_configs(self, project): | ||
run_dbt(["compile"]) | ||
|
||
generated_sql = read_file("target", "compiled", "test", "models", "model.sql") | ||
assert generated_sql == 'select * from "source_database"."source_schema"."customers"' | ||
|
||
|
||
class TestModelQuoting: | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
# Postgres quoting configs are True by default -- turn them all to False to show they are respected during model rendering | ||
return { | ||
"quoting": { | ||
"database": False, | ||
"schema": False, | ||
"identifier": False, | ||
}, | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"model.sql": "select 1 as id", | ||
"model_downstream.sql": "select * from {{ ref('model') }}", | ||
} | ||
|
||
def test_models_respect_global_quoting_configs(self, project): | ||
run_dbt(["compile"]) | ||
|
||
generated_sql = read_file("target", "compiled", "test", "models", "model_downstream.sql") | ||
assert generated_sql == f"select * from dbt.{project.test_schema}.model" |