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

Implement snapshot improvements #462

Merged
merged 4 commits into from
Dec 20, 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
1 change: 1 addition & 0 deletions .changes/0.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

For information on prior major and minor releases, see their changelogs:

* [1.8](https://github.com/starburstdata/dbt-trino/blob/1.8.latest/CHANGELOG.md)
* [1.7](https://github.com/starburstdata/dbt-trino/blob/1.7.latest/CHANGELOG.md)
* [1.6](https://github.com/starburstdata/dbt-trino/blob/1.6.latest/CHANGELOG.md)
* [1.5](https://github.com/starburstdata/dbt-trino/blob/1.5.latest/CHANGELOG.md)
Expand Down
20 changes: 0 additions & 20 deletions .changes/1.8.0.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/1.8.1.md

This file was deleted.

8 changes: 0 additions & 8 deletions .changes/1.8.1/Fixes-20240703-140732.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions .changes/1.8.2.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.2/Dependencies-20240909-042743.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.2/Features-20240812-161625.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.2/Fixes-20240729-101114.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions .changes/1.8.3.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.3/Features-20241015-174143.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.3/Under the Hood-20241103-212520.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .changes/1.8.4.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.4/Under the Hood-20241120-191809.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions .changes/1.8.5.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.5/Features-20241211-095408.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.5/Fixes-20241126-125237.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions .changes/1.8.5/Fixes-20241206-132238.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .changes/1.8.5/Fixes-20241211-202907.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: Dependencies
body: Update dependencies
time: 2024-09-17T19:02:38.25676+02:00
time: 2024-12-18T15:51:03.624898+01:00
custom:
Author: damian3031
Issue: ""
PR: "435"
PR: "462"
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20241218-151645.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: Allow configuring of snapshot column names
time: 2024-12-18T15:16:45.941759+01:00
custom:
Author: damian3031
Issue: ""
PR: "462"
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20241218-153349.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: Enable setting current value of dbt_valid_to
time: 2024-12-18T15:33:49.520897+01:00
custom:
Author: damian3031
Issue: ""
PR: "462"
66 changes: 1 addition & 65 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,11 @@
- Changes are listed under the (pre)release in which they first appear. Subsequent releases include changes from previous releases.
- "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version.
- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](https://github.com/starburstdata/dbt-trino/blob/master/CONTRIBUTING.md#adding-changelog-entry)
## dbt-trino 1.8.5 - December 11, 2024
### Features
- Add support for suppressing urllib3 cert warnings from logs ([#459](https://github.com/starburstdata/dbt-trino/issues/459), [#459](https://github.com/starburstdata/dbt-trino/pull/459))
### Fixes
- Fix breaking compatibility with Python 3.8 ([#452](https://github.com/starburstdata/dbt-trino/pull/452))
- Fix so that file_format and table_format config values do not require wrapping in single quotes ([#454](https://github.com/starburstdata/dbt-trino/issues/454), [#455](https://github.com/starburstdata/dbt-trino/pull/455))
- Allow boolean values in the cert parameter ([#460](https://github.com/starburstdata/dbt-trino/pull/460))

### Contributors
- [@colin-rogers-dbt](https://github.com/colin-rogers-dbt) ([#459](https://github.com/starburstdata/dbt-trino/pull/459))
- [@damian3031](https://github.com/damian3031) ([#452](https://github.com/starburstdata/dbt-trino/pull/452), [#455](https://github.com/starburstdata/dbt-trino/pull/455), [#460](https://github.com/starburstdata/dbt-trino/pull/460))
## dbt-trino 1.8.4 - November 22, 2024
### Under the Hood
- Revert cert default to False. Add require_certificate_validation Behavior Flag ([#447](https://github.com/starburstdata/dbt-trino/pull/447))

### Contributors
- [@damian3031](https://github.com/damian3031) ([#447](https://github.com/starburstdata/dbt-trino/pull/447))
## dbt-trino 1.8.3 - November 04, 2024
### Features
- Add file_format and table_format configurations ([#438](https://github.com/starburstdata/dbt-trino/pull/438))
### Under the Hood
- Enable SSL verification by default ([#441](https://github.com/starburstdata/dbt-trino/issues/441), [#442](https://github.com/starburstdata/dbt-trino/pull/442))

### Contributors
- [@damian3031](https://github.com/damian3031) ([#438](https://github.com/starburstdata/dbt-trino/pull/438))
- [@mdesmet](https://github.com/mdesmet) ([#442](https://github.com/starburstdata/dbt-trino/pull/442))
## dbt-trino 1.8.2 - September 24, 2024
### Features
- Added update_type and rowcount to dbt commands SQL status in CLI output ([#428](https://github.com/starburstdata/dbt-trino/issues/428), [#429](https://github.com/starburstdata/dbt-trino/pull/429))
### Fixes
- Change table materialization logic when on_table_exists = 'rename' ([#423](https://github.com/starburstdata/dbt-trino/issues/423), [#425](https://github.com/starburstdata/dbt-trino/pull/425))
### Dependencies
- Bump peter-evans/create-pull-request from 6 to 7 ([#433](https://github.com/starburstdata/dbt-trino/pull/433))
- Update dependencies ([#435](https://github.com/starburstdata/dbt-trino/pull/435))

### Contributors
- [@damian3031](https://github.com/damian3031) ([#429](https://github.com/starburstdata/dbt-trino/pull/429), [#435](https://github.com/starburstdata/dbt-trino/pull/435))
- [@dependabot[bot]](https://github.com/dependabot[bot]) ([#433](https://github.com/starburstdata/dbt-trino/pull/433))
- [@hovaesco](https://github.com/hovaesco) ([#425](https://github.com/starburstdata/dbt-trino/pull/425))
## dbt-trino 1.8.1 - July 04, 2024
### Fixes
- Fix incremental materialization to correctly set the temporary relation to a view or table ([#416](https://github.com/starburstdata/dbt-trino/issues/416), [#418](https://github.com/starburstdata/dbt-trino/pull/418))

### Contributors
- [@damian3031](https://github.com/damian3031) ([#418](https://github.com/starburstdata/dbt-trino/pull/418))
## dbt-trino 1.8.0 - May 09, 2024
### Features
- Support all types for unit testing ([#391](https://github.com/starburstdata/dbt-trino/issues/391), [#393](https://github.com/starburstdata/dbt-trino/pull/393))
- on_table_exists modes (rename, drop, replace) determine how table is recreated during a full-refresh run of an incremental model ([#395](https://github.com/starburstdata/dbt-trino/issues/395), [#406](https://github.com/starburstdata/dbt-trino/pull/406))
### Fixes
- Stop adding aliases to subqueries when calling with `--empty` ([#408](https://github.com/starburstdata/dbt-trino/pull/408))
### Under the Hood
- Add tests against Python 3.12 ([#383](https://github.com/starburstdata/dbt-trino/pull/383))
- Upgrade Trino to 439, SEP to 435-e.1 ([#388](https://github.com/starburstdata/dbt-trino/pull/388))
- Migrate to dbt-common and dbt-adapters package ([#387](https://github.com/starburstdata/dbt-trino/issues/387), [#390](https://github.com/starburstdata/dbt-trino/pull/390))
- Add tests for --empty flag ([#391](https://github.com/starburstdata/dbt-trino/issues/391), [#393](https://github.com/starburstdata/dbt-trino/pull/393))
- Update dependabot config to cover GHA ([#395](https://github.com/starburstdata/dbt-trino/pull/395))
### Dependencies
- Bump dev_requirements ([#388](https://github.com/starburstdata/dbt-trino/pull/388))
- Add `dbt-core` as a dependency to preserve backwards compatibility for installation ([#387](https://github.com/starburstdata/dbt-trino/issues/387), [#393](https://github.com/starburstdata/dbt-trino/pull/393))
- Updated dependencies and GH actions ([#408](https://github.com/starburstdata/dbt-trino/pull/408))
- Updated dbt-core to 1.8.0 ([#408](https://github.com/starburstdata/dbt-trino/pull/408))

### Contributors
- [@damian3031](https://github.com/damian3031) ([#393](https://github.com/starburstdata/dbt-trino/pull/393), [#406](https://github.com/starburstdata/dbt-trino/pull/406), [#408](https://github.com/starburstdata/dbt-trino/pull/408), [#383](https://github.com/starburstdata/dbt-trino/pull/383), [#388](https://github.com/starburstdata/dbt-trino/pull/388), [#390](https://github.com/starburstdata/dbt-trino/pull/390), [#393](https://github.com/starburstdata/dbt-trino/pull/393), [#395](https://github.com/starburstdata/dbt-trino/pull/395), [#388](https://github.com/starburstdata/dbt-trino/pull/388), [#393](https://github.com/starburstdata/dbt-trino/pull/393), [#408](https://github.com/starburstdata/dbt-trino/pull/408), [#408](https://github.com/starburstdata/dbt-trino/pull/408))
## Previous Releases

For information on prior major and minor releases, see their changelogs:

* [1.8](https://github.com/starburstdata/dbt-trino/blob/1.8.latest/CHANGELOG.md)
* [1.7](https://github.com/starburstdata/dbt-trino/blob/1.7.latest/CHANGELOG.md)
* [1.6](https://github.com/starburstdata/dbt-trino/blob/1.6.latest/CHANGELOG.md)
* [1.5](https://github.com/starburstdata/dbt-trino/blob/1.5.latest/CHANGELOG.md)
Expand Down
15 changes: 11 additions & 4 deletions dbt/include/trino/macros/materializations/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,22 @@
{% macro trino__snapshot_merge_sql(target, source, insert_cols) -%}
{%- set insert_cols_csv = insert_cols | join(', ') -%}

merge into {{ target }} as DBT_INTERNAL_DEST
{%- set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() -%}

merge into {{ target.render() }} as DBT_INTERNAL_DEST
using {{ source }} as DBT_INTERNAL_SOURCE
on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id
on DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }}

when matched
and DBT_INTERNAL_DEST.dbt_valid_to is null
{% if config.get("dbt_valid_to_current") %}
and (DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }} or
DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null)
{% else %}
and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
{% endif %}
and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')
then update
set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to
set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}

when not matched
and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'
Expand Down
8 changes: 4 additions & 4 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dbt-tests-adapter~=1.10.1
mypy==1.11.2 # patch updates have historically introduced breaking changes
pre-commit~=3.8
dbt-tests-adapter~=1.10.4
mypy==1.13.0 # patch updates have historically introduced breaking changes
pre-commit~=4.0
pytest~=8.3
tox~=4.18
tox~=4.23
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def _dbt_trino_version():
]
},
install_requires=[
"dbt-common>=1.0.4,<2.0",
"dbt-adapters>=1.1.1,<2.0",
"trino~=0.328",
"dbt-common>=1.14.0,<2.0",
"dbt-adapters>=1.10.4,<2.0",
"trino~=0.331",
# add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency
"dbt-core>=1.8.0",
],
Expand Down
Loading