-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbt: Add example project using
delete+insert
materialization
Ephemeral and incremental materialization using the `delete+insert` strategy.
- Loading branch information
Showing
11 changed files
with
111 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.user.yml | ||
target/ | ||
dbt_packages/ | ||
logs/ | ||
package-lock.yml |
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,25 @@ | ||
# dbt CrateDB example about model materialization | ||
|
||
## What's Inside | ||
Ephemeral and incremental materialization using the `delete+insert` | ||
strategy. | ||
|
||
## Setup | ||
```shell | ||
uv pip install -r requirements.txt | ||
``` | ||
|
||
## Usage | ||
|
||
Try running the following commands: | ||
- `dbt run` | ||
- `dbt test` | ||
|
||
Optionally, use `--debug` to display executed SQL statements. | ||
|
||
## Resources | ||
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction) | ||
- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers | ||
- Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support | ||
- Find [dbt events](https://events.getdbt.com) near you | ||
- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices |
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,12 @@ | ||
# Project name and metadata. | ||
name: 'testdrive_materialized' | ||
version: '1.0.0' | ||
config-version: 2 | ||
|
||
# Configure connection profile dbt uses for this project. | ||
profile: 'cratedb_localhost' | ||
|
||
# Directories to be removed by `dbt clean`. | ||
clean-targets: | ||
- "target" | ||
- "dbt_packages" |
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,3 @@ | ||
{{ config(materialized='ephemeral') }} | ||
|
||
select * from sys.jobs_log |
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,12 @@ | ||
{{ config(materialized='incremental', | ||
unique_key='id', | ||
incremental_strategy='delete+insert' | ||
) | ||
}} | ||
|
||
select * from {{ ref('jobslog') }} | ||
{% if is_incremental() %} | ||
|
||
where started >= (select max(started) from {{ this }}) | ||
|
||
{% endif %} |
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,3 @@ | ||
packages: | ||
- package: dbt-labs/dbt_utils | ||
version: 1.3.0 |
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,12 @@ | ||
cratedb_localhost: | ||
outputs: | ||
dev: | ||
type: cratedb | ||
host: localhost | ||
user: crate | ||
pass: crate | ||
port: 5432 | ||
dbname: crate | ||
schema: doc | ||
catalog: crate | ||
target: dev |
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 @@ | ||
dbt-cratedb2>=0.0.1 |
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,25 @@ | ||
models: | ||
- name: test | ||
columns: | ||
- name: id | ||
data_tests: | ||
- unique | ||
- not_null | ||
- name: started | ||
data_tests: | ||
- unique | ||
- not_null | ||
- name: classification['type'] | ||
data_tests: | ||
- accepted_values: | ||
values: ['SELECT', 'INSERT', 'DELETE', 'DDL', 'MANAGEMENT', 'UNDEFINED'] | ||
- name: started | ||
data_tests: | ||
- dbt_utils.accepted_range: | ||
min_value: 1734815733815 | ||
max_value: "now()" | ||
|
||
#- name: classification['labels'] | ||
# data_tests: | ||
# - accepted_values: | ||
# values: [[], ["Collect"], ["Collect", "Order"], ["Collect", "Union"], ["Collect", "GroupHashAggregate"], ["Collect", "GroupHashAggregate", "Order"], ["InsertFromValues"], ["TableFunction"]] |