Skip to content

Commit afecc40

Browse files
authored
Merge pull request #573 from dbt-labs/feat/new-sl-spec-support
2 parents 87b457c + b72121b commit afecc40

101 files changed

Lines changed: 1495 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/fusion.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,42 @@ env:
2626
PYTHON_VERSION: "3.11"
2727

2828
jobs:
29-
run-tests:
29+
run-duckdb-tests:
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read
33+
34+
steps:
35+
- name: "Checkout PR code"
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
39+
40+
- name: "Set up Python ${{ env.PYTHON_VERSION }}"
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: ${{ env.PYTHON_VERSION }}
44+
45+
- name: "Install dbt Fusion"
46+
run: |
47+
curl -fsSL https://public.cdn.getdbt.com/fs/install/install.sh | sh
48+
echo "$HOME/.local/bin" >> $GITHUB_PATH
49+
50+
- name: "Verify Fusion installation"
51+
run: |
52+
dbt --version
53+
54+
- name: "Install tox"
55+
run: |
56+
python -m pip install --upgrade pip
57+
pip install tox
58+
59+
- name: "Run Fusion integration tests on duckdb"
60+
run: |
61+
tox -e dbt_integration_fusion_duckdb
62+
63+
run-cloud-tests:
64+
needs: run-duckdb-tests
3065
runs-on: ubuntu-latest
3166
environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'cloud-tests' || '' }}
3267
strategy:

integration_tests_sl/.envrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export SNOWFLAKE_ACCOUNT=zna84829
2+
export SNOWFLAKE_USER=benoit_p
3+
export DBT_ENV_SECRET_SNOWFLAKE_PASS=zcq4wrv@VNJ8jvh2unv
4+
export SNOWFLAKE_ROLE=TRANSFORMER
5+
export SNOWFLAKE_DATABASE=analytics
6+
export SNOWFLAKE_WAREHOUSE=TRANSFORMING
7+

integration_tests_sl/.user.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
id: 86a16d1b-e324-4f8f-b626-bb8e31b1cd1a

integration_tests_sl/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Test dbt Project
2+
3+
The models within this folder (barring those in models/audit_schema_tests) represent a dbt project with poor DAG modeling. Error detection tools within this package are tested on this dbt project.
4+
5+
<img width="1377" alt="DAG of the test dbt project" src="https://user-images.githubusercontent.com/73915542/170353654-58ad303c-adaa-49f6-86b8-723543eb2d3d.png">
6+
7+
## Adding an Integration Test
8+
Create a seed which matches the intended output of your model and add equality tests comparing the output to your seed to the output of your model.
9+
10+
## Local tests
11+
12+
### AWS Athena
13+
14+
To run tests locally, please follow instructions:
15+
16+
* Set up environment variables:
17+
18+
```bash
19+
ATHENA_S3_STAGING_DIR=
20+
ATHENA_S3_DATA_DIR=
21+
ATHENA_REGION=
22+
ATHENA_SCHEMA=
23+
ATHENA_WORKGROUP=
24+
```
25+
26+
* Add `profiles.yml` file based on [sample](ci/sample.profiles.yml):
27+
28+
```yaml
29+
athena: # for local tests only
30+
type: athena
31+
s3_staging_dir: {{ env_var('ATHENA_S3_STAGING_DIR') }}
32+
s3_data_dir: {{ env_var('ATHENA_S3_DATA_DIR') }}
33+
s3_data_naming: schema_table_unique
34+
region_name: {{ env_var('ATHENA_REGION') }}
35+
schema: {{ env_var('ATHENA_SCHEMA') }}
36+
database: awsdatacatalog
37+
work_group: {{ env_var('ATHENA_WORKGROUP') }}
38+
num_retries: 2
39+
threads: 4
40+
```
41+
42+
* Now you can run integration tests, see details [here](../run_test.sh) with `--target athena` flag for dbt commands.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
# Name your project! Project names should contain only lowercase characters
3+
# and underscores. A good package name should reflect your organization's
4+
# name or the intended use of these models
5+
name: 'dbt_project_evaluator_integration_tests'
6+
version: '1.0.0'
7+
config-version: 2
8+
9+
# This setting configures which "profile" dbt uses for this project.
10+
profile: 'integration_tests'
11+
12+
# These configurations specify where dbt should look for different types of files.
13+
# The `source-paths` config, for example, states that models in this project can be
14+
# found in the "models/" directory. You probably won't need to change these!
15+
model-paths: ["models"]
16+
analysis-paths: ["analysis"]
17+
test-paths: ["tests"]
18+
seed-paths: ["seeds"]
19+
macro-paths: ["macros"]
20+
snapshot-paths: ["snapshots"]
21+
22+
target-path: "target" # directory which will store compiled SQL files
23+
clean-targets: # directories to be removed by `dbt clean`
24+
- "target"
25+
- "dbt_packages"
26+
27+
dispatch:
28+
- macro_namespace: dbt
29+
search_order: ['dbt_project_evaluator', 'dbt']
30+
31+
flags:
32+
require_nested_cumulative_type_params: True
33+
require_yaml_configuration_for_mf_time_spines: True
34+
require_generic_test_arguments_property: True
35+
require_ref_prefers_node_package_to_root: True
36+
37+
models:
38+
dbt_project_evaluator_integration_tests:
39+
# materialize as ephemeral to prevent the fake models from executing, but keep them enabled
40+
+materialized: ephemeral
41+
dbt_project_evaluator:
42+
marts:
43+
tests:
44+
fct_test_coverage:
45+
# materialize as a table to ensure SQL query runs successfully
46+
+materialized: table
47+
documentation:
48+
fct_documentation_coverage:
49+
# materialize as a table to ensure SQL query runs successfully
50+
+materialized: table
51+
52+
tests:
53+
dbt_project_evaluator:
54+
+enabled: false
55+
dbt_project_evaluator_integration_tests:
56+
dbt_project_evaluator_schema_tests:
57+
unique_int_all_dag_relationships_dpe_path:
58+
# Grouping by expressions of type ARRAY is not allowed for BigQuery
59+
+enabled: "{{ false if target.type in ['bigquery'] else true }}"
60+
61+
seeds:
62+
dbt_project_evaluator:
63+
dbt_project_evaluator_exceptions:
64+
+enabled: false
65+
66+
vars:
67+
# Set to true when running with dbt Fusion to disable tests that are not compatible
68+
deactivate_for_fusion: false
69+
# ensure integration tests run successfully when there are 0 of a given model type (extra)
70+
exclude_packages: ['exclude_package']
71+
exclude_paths_from_project: ["/to_exclude/","source_3.table_6","/dbt_project_evaluator_schema_tests/"]
72+
model_types: ['base','staging', 'intermediate', 'marts', 'other', 'extra', 'new_model_type']
73+
# dummy variable used for testing fct_hard_coded_references
74+
my_table_reference: 'grace_table'
75+
new_model_type_folder_name: 'my_new_models'
76+
new_model_type_prefixes: 'nwmdl_'
77+
insert_batch_size: 100
78+
too_many_joins_threshold: 3
79+
chained_views_threshold: 2
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# Name your project! Project names should contain only lowercase characters
3+
# and underscores. A good package name should reflect your organization's
4+
# name or the intended use of these models
5+
name: 'exclude_package'
6+
version: '1.0.0'
7+
config-version: 2
8+
9+
# This setting configures which "profile" dbt uses for this project.
10+
profile: 'integration_tests'
11+
12+
# These configurations specify where dbt should look for different types of files.
13+
# The `source-paths` config, for example, states that models in this project can be
14+
# found in the "models/" directory. You probably won't need to change these!
15+
model-paths: ["models"]
16+
analysis-paths: ["analysis"]
17+
test-paths: ["tests"]
18+
seed-paths: ["seeds"]
19+
macro-paths: ["macros"]
20+
snapshot-paths: ["snapshots"]
21+
22+
target-path: "target" # directory which will store compiled SQL files
23+
clean-targets: # directories to be removed by `dbt clean`
24+
- "target"
25+
- "dbt_packages"
26+
27+
models:
28+
exclude_package:
29+
# materialize as ephemeral to prevent the fake models from executing, but keep them enabled
30+
+materialized: view
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
models:
2+
- name: excluded_model
3+
config:
4+
access: public
5+
contract:
6+
enforced: true
7+
columns:
8+
- name: id
9+
data_type: "{{ 'UInt8' if target.type in ['clickhouse'] else 'integer' }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
- name: fake_source
3+
tables:
4+
- name: fake_source
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- {{ source('fake_source', 'fake_source') }}
2+
select 1 as id
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 2
2+
3+
models:
4+
- name: int_all_dag_relationships_dpe
5+
description: "This table shows one record for every resource and each of its downstream children (including itself). It includes models, snapshots, exposures, metrics and seeds"
6+
columns:
7+
- name: path
8+
description: unique identifier representing a distinct path from each resource to another resource
9+
data_tests:
10+
- unique
11+
- not_null
12+
13+
- name: int_all_graph_resources_dpe
14+
description: "This table shows one record for each enabled resource in the graph and information about that resource."
15+
columns:
16+
- name: resource_id
17+
data_tests:
18+
- unique
19+
- not_null
20+
- name: on_schema_change
21+
description: this contains the on_schema_change setting for incremental models. This column was sometimes an empty string, so should be tested to detect regressions
22+
data_tests:
23+
- not_null:
24+
config:
25+
where: "resource_type = 'model' and materialized = 'incremental'"
26+
- name: model_type
27+
data_tests:
28+
- dbt_utils.expression_is_true:
29+
arguments:
30+
expression: "= 'base'"
31+
config:
32+
where: "resource_name = 'base_model_10'"
33+
34+
- name: int_direct_relationships_dpe
35+
description: "This table shows one record for each direct parent/child pair in the graph."
36+
columns:
37+
- name: unique_id
38+
data_tests:
39+
- unique
40+
- not_null

0 commit comments

Comments
 (0)