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

feat(FIR-10764): Snapshot support #146

Merged
merged 3 commits into from
Sep 17, 2024
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
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
Loading