Skip to content

Commit

Permalink
Merge pull request #25 from firebolt-db/workaround-for-view-also
Browse files Browse the repository at this point in the history
view workaround for get_relation bug
  • Loading branch information
dataders authored Dec 2, 2021
2 parents 3b2e54e + b2ff2ae commit f8c36f7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 3 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/firebolt/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.21.5'
version = '0.21.4'
24 changes: 15 additions & 9 deletions dbt/include/firebolt/macros/materializations/view.sql
Original file line number Diff line number Diff line change
@@ -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') -%}
Expand Down

0 comments on commit f8c36f7

Please sign in to comment.