Skip to content

Commit

Permalink
Merge pull request #40 from fishtown-analytics/0.18.0
Browse files Browse the repository at this point in the history
0.18.0 compatibility
  • Loading branch information
Claire Carroll authored Sep 4, 2020
2 parents 3f094ff + 90a58ea commit 55e3fef
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
4 changes: 2 additions & 2 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ version: '0.3.0'

config-version: 2

require-dbt-version: ">=0.17.0"
require-dbt-version: ">=0.18.0"

source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
Expand Down
12 changes: 7 additions & 5 deletions macros/external/create_external_table.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% macro create_external_table(source_node) %}
{{ adapter_macro('dbt_external_tables.create_external_table', source_node) }}
{{ adapter.dispatch('create_external_table',
packages = dbt_external_tables._get_dbt_external_tables_namespaces())
(source_node) }}
{% endmacro %}

{% macro default__create_external_table(source_node) %}
Expand Down Expand Up @@ -30,7 +32,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) %}
Expand Down Expand Up @@ -62,7 +64,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 #}
Expand Down Expand Up @@ -93,12 +95,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 %}
4 changes: 3 additions & 1 deletion macros/external/refresh_external_table.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% macro refresh_external_table(source_node) %}
{{ return(adapter_macro('dbt_external_tables.refresh_external_table', source_node)) }}
{{ return(adapter.dispatch('refresh_external_table',
packages = dbt_external_tables._get_dbt_external_tables_namespaces())
(source_node)) }}
{% endmacro %}

{% macro default__refresh_external_table(source_node) %}
Expand Down
9 changes: 5 additions & 4 deletions macros/external/stage_external_sources.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% macro get_external_build_plan(source_node) %}
{{ return(adapter_macro('dbt_external_tables.get_external_build_plan', source_node)) }}
{{ return(adapter.dispatch('get_external_build_plan',
packages = dbt_external_tables._get_dbt_external_tables_namespaces())
(source_node)) }}
{% endmacro %}

{% macro default__get_external_build_plan(source_node) %}
Expand Down Expand Up @@ -116,17 +118,16 @@

{% do dbt_utils.log_info(loop_label ~ ' SKIP') if run_queue == [] %}

{% do dbt_external_tables.exit_transaction() %}

{% for q in run_queue %}

{% set q_msg = q|trim %}
{% set q_log = q_msg[:50] ~ '... ' if q_msg|length > 50 else q_msg %}

{% do dbt_utils.log_info(loop_label ~ ' (' ~ loop.index ~ ') ' ~ q_log) %}
{% set exit_txn = dbt_external_tables.exit_transaction() %}

{% call statement('runner', fetch_result = True, auto_begin = False) %}
{{ q }}
{{ exit_txn }} {{ q }}
{% endcall %}

{% set status = load_result('runner')['status'] %}
Expand Down
2 changes: 1 addition & 1 deletion macros/helpers/common.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% set package_context = context[package_name] %}
{% else %}
{% set error_msg %}
In adapter_macro: could not find package '{{package_name}}', called with '{{original_name}}'
Could not find package '{{package_name}}', called by macro '{{original_name}}'
{% endset %}
{{ exceptions.raise_compiler_error(error_msg | trim) }}
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions macros/helpers/get_external_tables_namespace.sql
Original file line number Diff line number Diff line change
@@ -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 %}
6 changes: 3 additions & 3 deletions macros/helpers/redshift/transaction.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% macro exit_transaction() %}
{{ return(adapter_macro('dbt_external_tables.exit_transaction')) }}
{{ return(adapter.dispatch('exit_transaction', dbt_external_tables._get_dbt_external_tables_namespaces())()) }}
{% endmacro %}

{% macro default__exit_transaction() %}
{# noop #}
{{ return('') }}
{% endmacro %}

{% macro redshift__exit_transaction() %}
{% do run_query('begin; commit;') %}
{{ return('begin; commit;') }}
{% endmacro %}
2 changes: 1 addition & 1 deletion packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
- package: fishtown-analytics/dbt_utils
version: [">=0.4.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]

0 comments on commit 55e3fef

Please sign in to comment.