From 793efb47d798163fcd000984129d2a2754da912e Mon Sep 17 00:00:00 2001 From: Claire Carroll <20294432+clrcrl@users.noreply.github.com> Date: Thu, 3 Sep 2020 16:35:33 -0400 Subject: [PATCH] Use dispatch macro --- macros/external/create_external_table.sql | 10 +++++----- macros/helpers/get_external_tables_namespace.sql | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 macros/helpers/get_external_tables_namespace.sql diff --git a/macros/external/create_external_table.sql b/macros/external/create_external_table.sql index 2e10cb9f..df4e5018 100644 --- a/macros/external/create_external_table.sql +++ b/macros/external/create_external_table.sql @@ -1,5 +1,5 @@ {% macro create_external_table(source_node) %} - {{ adapter_macro('dbt_external_tables.create_external_table', source_node) }} + {{ adapter.dispatch('create_external_table', dbt_external_tables._get_dbt_external_tables_namespaces()) (source_node) }} {% endmacro %} {% macro default__create_external_table(source_node) %} @@ -30,7 +30,7 @@ {% if external.file_format -%} stored as {{external.file_format}} {%- endif %} {% if external.location -%} location '{{external.location}}' {%- endif %} {% if external.table_properties -%} table properties {{external.table_properties}} {%- endif %} - + {% endmacro %} {% macro spark__create_external_table(source_node) %} @@ -62,7 +62,7 @@ {%- set columns = source_node.columns.values() -%} {%- set external = source_node.external -%} {%- set partitions = external.partitions -%} - + {%- set is_csv = dbt_external_tables.is_csv(external.file_format) -%} {# https://docs.snowflake.net/manuals/sql-reference/sql/create-external-table.html #} @@ -93,12 +93,12 @@ {% macro bigquery__create_external_table(source_node) %} {{ exceptions.raise_compiler_error( - "BigQuery does not support creating external tables in SQL/DDL. + "BigQuery does not support creating external tables in SQL/DDL. Create it from the BQ console.") }} {% endmacro %} {% macro presto__create_external_table(source_node) %} {{ exceptions.raise_compiler_error( - "Presto does not support creating external tables with + "Presto does not support creating external tables with the Hive connector. Do so from Hive directly.") }} {% endmacro %} diff --git a/macros/helpers/get_external_tables_namespace.sql b/macros/helpers/get_external_tables_namespace.sql new file mode 100644 index 00000000..4dd60ca1 --- /dev/null +++ b/macros/helpers/get_external_tables_namespace.sql @@ -0,0 +1,4 @@ +{% macro _get_dbt_external_tables_namespaces() %} + {% set override_namespaces = var('dbt_external_tables_dispatch_list', []) %} + {% do return(override_namespaces + ['dbt_external_tables']) %} +{% endmacro %}