From ff5cb7ba51b4133f836d8d45ee8bb52f01ff4b4e Mon Sep 17 00:00:00 2001 From: lllong33 <29864358+lllong33@users.noreply.github.com> Date: Sat, 22 Jul 2023 05:28:27 +0800 Subject: [PATCH] Fixed double underline (#7944) * Fixed double-underline * backward compatibility postgres_get_relations * Remove invalid comments * compatibility adapter and get_relation * fix generic for call * fix adapter dispatch grammar issue --- .changes/unreleased/Fixes-20230625-142731.yaml | 6 ++++++ .../include/global_project/macros/adapters/metadata.sql | 9 +++++++++ plugins/postgres/dbt/adapters/postgres/impl.py | 3 +-- .../postgres/dbt/include/postgres/macros/relations.sql | 6 +++++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixes-20230625-142731.yaml diff --git a/.changes/unreleased/Fixes-20230625-142731.yaml b/.changes/unreleased/Fixes-20230625-142731.yaml new file mode 100644 index 00000000000..593fd8b9733 --- /dev/null +++ b/.changes/unreleased/Fixes-20230625-142731.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fixed double-underline +time: 2023-06-25T14:27:31.231253719+08:00 +custom: + Author: lllong33 + Issue: "5301" diff --git a/core/dbt/include/global_project/macros/adapters/metadata.sql b/core/dbt/include/global_project/macros/adapters/metadata.sql index 3c334dae6b8..9e45c500a3f 100644 --- a/core/dbt/include/global_project/macros/adapters/metadata.sql +++ b/core/dbt/include/global_project/macros/adapters/metadata.sql @@ -63,3 +63,12 @@ {{ exceptions.raise_not_implemented( 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }} {% endmacro %} + +{% macro get_relations() %} + {{ return(adapter.dispatch('get_relations', 'dbt')()) }} +{% endmacro %} + +{% macro default__get_relations() %} + {{ exceptions.raise_not_implemented( + 'get_relations macro not implemented for adapter '+adapter.type()) }} +{% endmacro %} diff --git a/plugins/postgres/dbt/adapters/postgres/impl.py b/plugins/postgres/dbt/adapters/postgres/impl.py index 2fc8071efb8..adffc4d3a62 100644 --- a/plugins/postgres/dbt/adapters/postgres/impl.py +++ b/plugins/postgres/dbt/adapters/postgres/impl.py @@ -20,8 +20,7 @@ import dbt.utils -# note that this isn't an adapter macro, so just a single underscore -GET_RELATIONS_MACRO_NAME = "postgres_get_relations" +GET_RELATIONS_MACRO_NAME = "postgres__get_relations" @dataclass diff --git a/plugins/postgres/dbt/include/postgres/macros/relations.sql b/plugins/postgres/dbt/include/postgres/macros/relations.sql index 9966c5db2e8..dd50cf00163 100644 --- a/plugins/postgres/dbt/include/postgres/macros/relations.sql +++ b/plugins/postgres/dbt/include/postgres/macros/relations.sql @@ -1,4 +1,4 @@ -{% macro postgres_get_relations () -%} +{% macro postgres__get_relations() -%} {# -- in pg_depend, objid is the dependent, refobjid is the referenced object @@ -74,3 +74,7 @@ {{ return(load_result('relations').table) }} {% endmacro %} + +{% macro postgres_get_relations() %} + {{ return(postgres__get_relations()) }} +{% endmacro %}