From 3b0016974b96715516c98f210494e0ff03a4b3c8 Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Tue, 7 Nov 2023 17:38:36 +0800 Subject: [PATCH] Fix default dbt target decision policy Signed-off-by: Wei-Chun, Chang --- piperider_cli/configuration.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/piperider_cli/configuration.py b/piperider_cli/configuration.py index 714305f1a..d1ebf7eeb 100644 --- a/piperider_cli/configuration.py +++ b/piperider_cli/configuration.py @@ -1,3 +1,4 @@ +import copy import json import os import shlex @@ -558,17 +559,20 @@ def _load(cls, piperider_config_path=None, dbt_profile: str = None, dbt_target: if profile.get(profile_name): target_names = list(profile.get(profile_name).get('outputs').keys()) for target in target_names: + dbt_config = copy.deepcopy(dbt) credential = DbtUtil.load_credential_from_dbt_profile(profile, profile_name, target) if credential.get('pass') and credential.get('password') is None: credential['password'] = credential.pop('pass') datasource_class = DATASOURCE_PROVIDERS[credential.get('type')] - dbt.update(profile=profile_name, target=target) + dbt_config.update(profile=profile_name, target=target) data_source = datasource_class( name=target, - dbt=dict(dbt), + dbt=dict(dbt_config), credential=credential ) data_sources.append(data_source) + + dbt['profile'] = profile_name # dbt behavior: dbt uses 'default' as target name if no target given in profiles.yml dbt['target'] = dbt_target if dbt_target else dbt.get('target', profile.get(profile_name).get('target',