-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for referencing dbt snapshots in an Ibis model (#15)
* Adapt to new dbt_packages location in newer versions of dbt * Add support for referencing snapshots * Fix tests
- Loading branch information
Showing
10 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from dbt_ibis import depends_on, ref | ||
import ibis.expr.types | ||
|
||
|
||
# You can use a type hint to help your editor, e.g. VS Code, to provide | ||
# you with autocompletion suggestions. | ||
@depends_on(ref("orders_snapshot")) | ||
def model(orders_snapshot: ibis.expr.types.Table): | ||
return orders_snapshot.relabel({"id": "order_id", "user_id": "customer_id"}).select( | ||
"order_id", "customer_id", "order_date", "status" | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% snapshot orders_snapshot %} | ||
|
||
{#- | ||
Normally we would select from the table here, but we are mostly using seeds to load | ||
our data in this demo project | ||
#} | ||
|
||
{{ | ||
config( | ||
target_database='db', | ||
target_schema='snapshots', | ||
unique_key='id', | ||
|
||
strategy='check', | ||
check_cols='all' | ||
) | ||
}} | ||
|
||
select * | ||
from {{ ref('raw_orders') }} | ||
|
||
{% endsnapshot %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: 2 | ||
|
||
snapshots: | ||
- name: orders_snapshot | ||
columns: | ||
- name: id | ||
data_type: integer | ||
- name: user_id | ||
data_type: integer | ||
- name: order_date | ||
data_type: date | ||
- name: status | ||
data_type: varchar | ||
- name: dbt_scd_id | ||
data_type: varchar | ||
- name: dbt_updated_at | ||
data_type: timestamp | ||
- name: dbt_valid_from | ||
data_type: timestamp | ||
- name: dbt_valid_to | ||
data_type: timestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters