diff --git a/CHANGELOG.md b/CHANGELOG.md index 02f3c0931..1541ae365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,16 @@ # Changelog -## v.0.21.5 +## v.0.21.4 ### Changes -- Added linting using Black, Flake8, and iSort. This necessitated the addition of a `setup.cfg` file, so an additional linter, `setup-cfg-fmt` was added to check that file. These linters are all pre-commit hooks, so will force any future commits to abide by our style. - +- views are now officially supported with dbt-firebolt! [#22](https://github.com/firebolt-db/dbt-firebolt/pull/22) and [#25](https://github.com/firebolt-db/dbt-firebolt/pull/25) ### Under the hood - added GitHub templates for PRs and issues - -## v.0.21.4 - -### Changes - -- views are not officially supported with dbt-firebolt! [#22](https://github.com/firebolt-db/dbt-firebolt/pull/22) +- Added linting using Black, Flake8, and iSort. This necessitated the addition of a `setup.cfg` file, so an additional linter, `setup-cfg-fmt` was added to check that file. These linters are all pre-commit hooks, so will force any future commits to abide by our style. [#20](https://github.com/firebolt-db/dbt-firebolt/pull/20) ## v.0.21.3 diff --git a/dbt/adapters/firebolt/__version__.py b/dbt/adapters/firebolt/__version__.py index 42ef8b01b..af225e313 100644 --- a/dbt/adapters/firebolt/__version__.py +++ b/dbt/adapters/firebolt/__version__.py @@ -1 +1 @@ -version = '0.21.5' +version = '0.21.4' diff --git a/dbt/include/firebolt/macros/materializations/view.sql b/dbt/include/firebolt/macros/materializations/view.sql index 7b5ad477a..751bf63aa 100644 --- a/dbt/include/firebolt/macros/materializations/view.sql +++ b/dbt/include/firebolt/macros/materializations/view.sql @@ -1,22 +1,28 @@ {% materialization view, adapter='firebolt' %} {# Note that a nearly identical materialization appears in table.sql #} - {%- set identifier = model['alias'] -%} - {%- set old_relation = adapter.get_relation(database=database, - schema=schema, - identifier=identifier) -%} + {%- set identifier = model['alias'] -%} {# alias comes from where? #} + + {# Temporary workaround to issue with adapter.get_relation() until + the following are resolved: + https://github.com/firebolt-db/dbt-firebolt/issues/11 + https://github.com/dbt-labs/dbt-core/issues/4187 + the hack is to always drop the view/table if it already exists rather than + checking the db first to see if it exists. + #} {%- set target_relation = api.Relation.create(database=database, schema=schema, identifier=identifier, type='view') -%} - {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%} - {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%} + {%- set target_relation_table = api.Relation.create(database=database, + schema=schema, + identifier=identifier, + type='table') -%} {{ run_hooks(pre_hooks) }} - {% if old_relation is not none %} - {% do adapter.drop_relation(old_relation) %} - {% endif %} + {% do adapter.drop_relation(target_relation) %} + {% do adapter.drop_relation(target_relation_table) %} -- build model {% call statement('main') -%}