Skip to content

Commit 35f9f39

Browse files
committed
dbt: Add example project using delete+insert materialization
Ephemeral and incremental materialization using the `delete+insert` strategy.
1 parent 90bb5b2 commit 35f9f39

File tree

11 files changed

+111
-0
lines changed

11 files changed

+111
-0
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ updates:
112112
schedule:
113113
interval: "daily"
114114

115+
- directory: "/framework/dbt/materialize"
116+
package-ecosystem: "pip"
117+
schedule:
118+
interval: "daily"
119+
115120
- directory: "/framework/gradio"
116121
package-ecosystem: "pip"
117122
schedule:

.github/workflows/framework-dbt.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,11 @@ jobs:
6969
pip install -r requirements.txt
7070
dbt run --debug
7171
dbt test --debug
72+
73+
- name: Validate framework/dbt/materialize
74+
run: |
75+
cd framework/dbt/materialize
76+
pip install -r requirements.txt
77+
dbt deps
78+
dbt run --debug
79+
dbt test --debug
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.user.yml
2+
target/
3+
dbt_packages/
4+
logs/
5+
package-lock.yml
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# dbt CrateDB example about model materialization
2+
3+
## What's Inside
4+
Ephemeral and incremental materialization using the `delete+insert`
5+
strategy.
6+
7+
## Setup
8+
```shell
9+
uv pip install -r requirements.txt
10+
```
11+
12+
## Usage
13+
14+
Try running the following commands:
15+
- `dbt run`
16+
- `dbt test`
17+
18+
Optionally, use `--debug` to display executed SQL statements.
19+
20+
## Resources
21+
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction)
22+
- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers
23+
- Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support
24+
- Find [dbt events](https://events.getdbt.com) near you
25+
- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Project name and metadata.
2+
name: 'testdrive_materialized'
3+
version: '1.0.0'
4+
config-version: 2
5+
6+
# Configure connection profile dbt uses for this project.
7+
profile: 'cratedb_localhost'
8+
9+
# Directories to be removed by `dbt clean`.
10+
clean-targets:
11+
- "target"
12+
- "dbt_packages"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ config(materialized='ephemeral') }}
2+
3+
select * from sys.jobs_log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{ config(materialized='incremental',
2+
unique_key='id',
3+
incremental_strategy='delete+insert'
4+
)
5+
}}
6+
7+
select * from {{ ref('jobslog') }}
8+
{% if is_incremental() %}
9+
10+
where started >= (select max(started) from {{ this }})
11+
12+
{% endif %}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages:
2+
- package: dbt-labs/dbt_utils
3+
version: 1.3.0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cratedb_localhost:
2+
outputs:
3+
dev:
4+
type: cratedb
5+
host: localhost
6+
user: crate
7+
pass: crate
8+
port: 5432
9+
dbname: crate
10+
schema: doc
11+
catalog: crate
12+
target: dev
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dbt-cratedb2>=0.0.1

0 commit comments

Comments
 (0)