dbt-labs / dbt-external-tables

dbt macros to stage external sources
https://hub.getdbt.com/dbt-labs/dbt_external_tables/latest/
Apache License 2.0
294 stars 119 forks source link

add namespace to redshift_is_ext_tbl call in get_external_build_plan #168

Closed MikeSchriefer closed 1 year ago

MikeSchriefer commented 1 year ago

Description & motivation

When staging external tables as an on-run-start hook, as in

on-run-start:
  - "{% if target.name == 'prod' and var('refresh_external_tables')%}{{ dbt_external_tables.stage_external_sources() }}{% endif %}"

the macro fails with

Runtime Error
  Compilation Error in operation redshift-on-run-start-1 (./dbt_project.yml)
    'redshift_is_ext_tbl' is undefined
    > in macro get_external_build_plan (macros/common/get_external_build_plan.sql)
    > called by macro stage_external_sources (macros/common/stage_external_sources.sql)
    > called by macro redshift__get_external_build_plan (macros/plugins/redshift/get_external_build_plan.sql)
    > called by operation stratasan_redshift-on-run-start-1 (./dbt_project.yml)

When running the macro from the CLI I get the expected results of building/rebuilding/skipping the table.

The issue was fixed with referencing the redshift_is_ext_tbl macro by its namespace, as in dbt_external_tables.redshift_is_ext_tbl

Checklist