From 93e5a11231021264b10a192140cd1a4081309d36 Mon Sep 17 00:00:00 2001 From: "Ching Yi, Chan" Date: Thu, 24 Aug 2023 03:11:32 +0000 Subject: [PATCH] [Bug] fix compatible problem for dbt-1.3 and dbt-1.6.1 (#859) * Fix flag creation (dbt-1.3 compatible) Signed-off-by: Ching Yi, Chan * Add flag for the v1.6.1 Signed-off-by: Ching Yi, Chan --------- Signed-off-by: Ching Yi, Chan --- piperider_cli/dbt/list_task.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/piperider_cli/dbt/list_task.py b/piperider_cli/dbt/list_task.py index cc7709ee5..c77c20e08 100644 --- a/piperider_cli/dbt/list_task.py +++ b/piperider_cli/dbt/list_task.py @@ -230,7 +230,8 @@ def _get_v15_runtime_config(flags): flags ) - flags = flags_module.get_flag_obj() + flags = make_flag() + setattr(flags, 'target_path', target_path) setattr(flags, "WRITE_JSON", None) setattr(flags, "exclude", None) @@ -246,7 +247,6 @@ def _get_v15_runtime_config(flags): setattr(flags, "target", None) v = dbt_version - if v == '1.5' or v == '1.6': return _get_v15_runtime_config(flags) elif v == '1.4': @@ -257,6 +257,17 @@ def _get_v15_runtime_config(flags): raise NotImplementedError(f'dbt-core version: {v} is not supported') +def make_flag(): + v = dbt_version + if v == '1.3': + flags = argparse.Namespace(USE_COLORS=True) + else: + flags = flags_module.get_flag_obj() + setattr(flags, 'PARTIAL_PARSE_FILE_DIFF', True) + + return flags + + def _configure_warn_error_options(flags): if dbt_version >= '1.4': from dbt.helper_types import WarnErrorOptions @@ -339,7 +350,7 @@ def validate(self): class _DbtListTask(ListTask): def __init__(self): self.config = _RuntimeConfig() - self.args = flags_module.get_flag_obj() + self.args = make_flag() self.previous_state = None if dbt_version >= '1.5' and hasattr(flags_module, 'set_flags'):