Skip to content

Commit

Permalink
feat(FIR-10764): Snapshot support (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptiurin authored Sep 17, 2024
1 parent ff0ed62 commit 2babd73
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240912-162707.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Snapshot support
time: 2024-09-12T16:27:07.67185+01:00
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The table below shows which dbt and Firebolt features are supported by the adapt
| Incremental materializations - insert_overwrite | :white_check_mark: |
| Incremental materializations - delete+insert | :white_check_mark: |
| Incremental materializations - merge | :x: |
| Snapshots | :x: |
| Snapshots | :white_check_mark: |
| Seeds | :white_check_mark: |
| Tests | :white_check_mark: |
| Documentation | :white_check_mark: |
Expand Down
19 changes: 19 additions & 0 deletions dbt/include/firebolt/macros/materializations/snapshot_merge.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% macro firebolt__snapshot_merge_sql(target, source, insert_cols) -%}
{%- set insert_cols_csv = insert_cols | join(', ') -%}

UPDATE {{ target.render() }} AS DBT_INTERNAL_DEST
SET dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to
FROM {{ source }} AS DBT_INTERNAL_SOURCE
WHERE DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id
AND DBT_INTERNAL_DEST.dbt_valid_to IS NULL
AND DBT_INTERNAL_SOURCE.dbt_change_type IN ('update', 'delete');

INSERT INTO {{ target.render() }} ({{ insert_cols_csv }})
SELECT {{ insert_cols_csv }}
FROM {{ source }} AS DBT_INTERNAL_SOURCE
WHERE DBT_INTERNAL_SOURCE.dbt_scd_id NOT IN (
SELECT dbt_scd_id FROM {{ target.render() }}
)
AND DBT_INTERNAL_SOURCE.dbt_change_type = 'insert';

{% endmacro %}
4 changes: 4 additions & 0 deletions dbt/include/firebolt/macros/relations/table/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
) }}
{%- endif -%}
{%- if temporary -%}
{%- do adapter.drop_relation(relation) -%}
{%- endif -%}
{%- set table_type = config.get(
'table_type',
default = 'dimension'
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/adapter/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,10 @@ class TestGenericTestsFirebolt(BaseGenericTests):
pass


@mark.skip('Not implemented for v1')
class TestSnapshotCheckColsFirebolt(BaseSnapshotCheckCols):
pass


@mark.skip('Not implemented for v1')
class TestSnapshotTimestampFirebolt(BaseSnapshotTimestamp):
pass

Expand Down

0 comments on commit 2babd73

Please sign in to comment.