Skip to content

Commit

Permalink
Merge pull request #40 from flexanalytics/handle-model-not-exists
Browse files Browse the repository at this point in the history
ignore models if they do not exist
  • Loading branch information
MiConnell authored Sep 25, 2024
2 parents 74f04ab + 2af8e7d commit 2b38403
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions macros/upload_models.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
{% endif %}

{% for model in models -%}
{%- set model_relation = adapter.get_relation(database=model.database, schema=model.schema, identifier=model.name) -%}
{% set table_exists=model_relation is not none %}

{% if model.config.materialized in ["table","incremental"] %}
{% if table_exists and model.config.materialized in ["table","incremental"] %}
{% if target.type == 'snowflake' %}
{%- set rowcount_query %}
select row_count as model_rowcount
Expand Down Expand Up @@ -83,8 +85,10 @@
{% if models != [] %}
{% set model_values %}
{% for model in models -%}
{%- set model_relation = adapter.get_relation(database=model.database, schema=model.schema, identifier=model.name) -%}
{% set table_exists=model_relation is not none %}

{% if model.config.materialized in ["table","incremental"] %}
{% if table_exists and model.config.materialized in ["table","incremental"] %}
{%- set rowcount_query %}
select count(*) as model_rowcount from {{ model.schema }}.{{ model.name }}
{%- endset -%}
Expand Down

0 comments on commit 2b38403

Please sign in to comment.