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

add builder config to test node config #10767

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240925-154514.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Pass test user config to adapter pre_hook by explicitly adding test builder config to node
time: 2024-09-25T15:45:14.459598-07:00
custom:
Author: colin-rogers-dbt
Issue: "10484"
10 changes: 8 additions & 2 deletions core/dbt/context/context_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from dbt.adapters.factory import get_config_class_by_name
from dbt.config import IsFQNResource, Project, RuntimeConfig
from dbt.contracts.graph.model_config import get_config_for
from dbt.exceptions import SchemaConfigError
from dbt.flags import get_flags
from dbt.node_types import NodeType
from dbt.utils import fqn_search
from dbt_common.contracts.config.base import BaseConfig, merge_config_dicts
from dbt_common.dataclass_schema import ValidationError
from dbt_common.exceptions import DbtInternalError


Expand Down Expand Up @@ -237,8 +239,12 @@ def calculate_node_config_dict(
base=base,
patch_config_dict=patch_config_dict,
)
finalized = config.finalize_and_validate()
return finalized.to_dict(omit_none=True)
try:
finalized = config.finalize_and_validate()
return finalized.to_dict(omit_none=True)
except ValidationError as exc:
# we got a ValidationError - probably bad types in config()
raise SchemaConfigError(exc, node=config) from exc


class UnrenderedConfigGenerator(BaseContextConfigGenerator[Dict[str, Any]]):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/schema_generic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def parse_generic_test(

# this is the ContextConfig that is used in render_update
config: ContextConfig = self.initial_config(fqn)

config.add_config_call(builder.config)
# builder.args contains keyword args for the test macro,
# not configs which have been separated out in the builder.
# The keyword args are not completely rendered until compilation.
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/schema_tests/data_test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def models(self):
return {"table.sql": table_sql, "custom_config.yml": custom_config_yml}

def test_custom_config(self, project):
run_dbt(["parse"])
manifest = get_manifest(project.project_root)
run_dbt(["run"])
run_dbt(["test"], expect_pass=False)

manifest = get_manifest(project.project_root)
# Pattern to match the test_id without the specific suffix
pattern = re.compile(r"test\.test\.accepted_values_table_color__blue__red\.\d+")

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/schema_tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@
8,green,80
9,yellow,90
10,blue,100
"""
""".strip()

table_sql = """
-- content of the table.sql
Expand Down
Loading