-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into release-1.8.1
- Loading branch information
Showing
13 changed files
with
306 additions
and
12 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,12 @@ | ||
name: 'my_dbt_project' | ||
version: '1.0.0' | ||
config-version: 2 | ||
|
||
profile: 'default' | ||
|
||
model-paths: ["models"] | ||
test-paths: ["tests"] | ||
|
||
models: | ||
my_dbt_project: | ||
materialized: view |
17 changes: 17 additions & 0 deletions
17
dev/dags/dbt/multiple_parents_test/macros/custom_test_combined_model.sql
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,17 @@ | ||
{% test custom_test_combined_model(model) %} | ||
WITH source_data AS ( | ||
SELECT id FROM {{ ref('model_a') }} | ||
), | ||
combined_data AS ( | ||
SELECT id FROM {{ model }} | ||
) | ||
SELECT | ||
s.id | ||
FROM | ||
source_data s | ||
LEFT JOIN | ||
combined_data c | ||
ON s.id = c.id | ||
WHERE | ||
c.id IS NULL | ||
{% endtest %} |
16 changes: 16 additions & 0 deletions
16
dev/dags/dbt/multiple_parents_test/models/combined_model.sql
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,16 @@ | ||
-- Combine data from model_a and model_b | ||
WITH model_a AS ( | ||
SELECT * FROM {{ ref('model_a') }} | ||
), | ||
model_b AS ( | ||
SELECT * FROM {{ ref('model_b') }} | ||
) | ||
SELECT | ||
a.id, | ||
a.name, | ||
b.created_at | ||
FROM | ||
model_a AS a | ||
JOIN | ||
model_b AS b | ||
ON a.id = b.id |
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,4 @@ | ||
-- Create a simple table | ||
SELECT 1 AS id, 'Alice' AS name | ||
UNION ALL | ||
SELECT 2 AS id, 'Bob' AS name |
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,4 @@ | ||
-- Create another simple table | ||
SELECT 1 AS id, '2024-12-25'::date AS created_at | ||
UNION ALL | ||
SELECT 2 AS id, '2024-12-26'::date AS created_at |
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,32 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: model_a | ||
description: "A simple model with user data" | ||
tests: | ||
- unique: | ||
column_name: id | ||
|
||
- name: model_b | ||
description: "A simple model with date data" | ||
tests: | ||
- unique: | ||
column_name: id | ||
|
||
- name: combined_model | ||
description: "Combines data from model_a and model_b" | ||
columns: | ||
- name: id | ||
tests: | ||
- not_null | ||
|
||
- name: name | ||
tests: | ||
- not_null | ||
|
||
- name: created_at | ||
tests: | ||
- not_null | ||
|
||
tests: | ||
- custom_test_combined_model: {} |
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 @@ | ||
default: | ||
target: dev | ||
outputs: | ||
dev: | ||
type: postgres | ||
host: "{{ env_var('POSTGRES_HOST') }}" | ||
user: "{{ env_var('POSTGRES_USER') }}" | ||
password: "{{ env_var('POSTGRES_PASSWORD') }}" | ||
port: "{{ env_var('POSTGRES_PORT') | int }}" | ||
dbname: "{{ env_var('POSTGRES_DB') }}" | ||
schema: "{{ env_var('POSTGRES_SCHEMA') }}" | ||
threads: 4 |
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,34 @@ | ||
""" | ||
An example DAG that uses Cosmos to render a dbt project into an Airflow DAG. | ||
""" | ||
|
||
import os | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
from cosmos import DbtDag, ProfileConfig, ProjectConfig | ||
from cosmos.profiles import PostgresUserPasswordProfileMapping | ||
|
||
DEFAULT_DBT_ROOT_PATH = Path(__file__).parent / "dbt" | ||
DBT_ROOT_PATH = Path(os.getenv("DBT_ROOT_PATH", DEFAULT_DBT_ROOT_PATH)) | ||
|
||
profile_config = ProfileConfig( | ||
profile_name="default", | ||
target_name="dev", | ||
profile_mapping=PostgresUserPasswordProfileMapping( | ||
conn_id="example_conn", | ||
profile_args={"schema": "public"}, | ||
disable_event_tracking=True, | ||
), | ||
) | ||
|
||
example_multiple_parents_test = DbtDag( | ||
# dbt/cosmos-specific parameters | ||
project_config=ProjectConfig( | ||
DBT_ROOT_PATH / "multiple_parents_test", | ||
), | ||
profile_config=profile_config, | ||
# normal dag parameters | ||
start_date=datetime(2023, 1, 1), | ||
dag_id="example_multiple_parents_test", | ||
) |
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
Oops, something went wrong.