Skip to content

Commit

Permalink
[Bug] fix compatible problem for dbt-1.3 and dbt-1.6.1 (#859)
Browse files Browse the repository at this point in the history
* Fix flag creation (dbt-1.3 compatible)

Signed-off-by: Ching Yi, Chan <[email protected]>

* Add flag for the v1.6.1

Signed-off-by: Ching Yi, Chan <[email protected]>

---------

Signed-off-by: Ching Yi, Chan <[email protected]>
  • Loading branch information
qrtt1 authored Aug 24, 2023
1 parent c6da5d0 commit 93e5a11
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions piperider_cli/dbt/list_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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':
Expand All @@ -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
Expand Down Expand Up @@ -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'):
Expand Down

0 comments on commit 93e5a11

Please sign in to comment.