Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp workaround for false approximate match #12

Merged
merged 6 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog


## v.0.21.3

## Changes

- temporary workaround for #11 where running models twice fails [#12](https://github.com/firebolt-db/dbt-firebolt/pull/12)

## v.0.21.2

### Readme
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.2"
version = "0.21.3"
22 changes: 14 additions & 8 deletions dbt/include/firebolt/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@
{# Note that a nearly identical materialization appears
in table.sql #}
{%- set identifier = model['alias'] -%} {# alias comes from where? #}
{%- set old_relation = adapter.get_relation(database=database,
schema=schema,
identifier=identifier) -%}

{# 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='table') -%}
{%- 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_view = api.Relation.create(database=database,
schema=schema,
identifier=identifier,
type='view') -%}

{{ 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_view) %}

-- build model
{% call statement('main') -%}
Expand Down