dbt-labs / dbt-audit-helper

Useful macros when performing data audits

Home Page:https://hub.getdbt.com/dbt-labs/audit_helper/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_columns_in_relation_sql returns an error during parse phase on Snowflake when using a created Relation

clrcrl opened this issue · comments

Offending code:

{% set old_etl_relation=adapter.get_relation(
      database=target.database,
      schema="ANALYTICS",
      identifier="DIM_ACCOUNTS"
) -%}
{{ audit_helper.get_columns_in_relation_sql(old_etl_relation) }}

Result:

Compilation Error in macro snowflake__get_columns_in_relation_sql (macros/compare_relation_columns.sql)
  'None' has no attribute 'information_schema'
  > in macro adapter_macro (macros/adapters/common.sql)
  > called by macro get_columns_in_relation_sql (macros/compare_relation_columns.sql)
  > called by macro compare_relation_columns (macros/compare_relation_columns.sql)
  > called by macro snowflake__get_columns_in_relation_sql (macros/compare_relation_columns.sql)

Workaround:
Wrap everything in an {% if execute %} statement

Investigation:
I believe this is because I call {{ relation.information_schema('columns') }}, but during the parse-phase I haven't yet created the relation

Likely happening on BQ and Postgres too

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.