Skip to content

Commit 3631d1d

Browse files
authored
Merge pull request #561 from dbt-labs/ci/add-fusion-snowflake-tests
2 parents 2371bd0 + 83781e6 commit 3631d1d

File tree

8 files changed

+118
-6
lines changed

8 files changed

+118
-6
lines changed

.github/workflows/fusion.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# **what?**
2+
# Run tests using dbt Fusion against Snowflake
3+
4+
# **why?**
5+
# To ensure that dbt-project-evaluator works as expected with dbt Fusion
6+
# This runs alongside (not replacing) the existing dbt-core tests
7+
8+
# **when?**
9+
# On every PR, and every push to main and when manually triggered
10+
11+
# **note**
12+
# Currently only Snowflake is tested with Fusion. Additional adapters can be
13+
# added to the matrix as Fusion support expands. Credentials are shared with
14+
# the existing dbt-core Snowflake tests.
15+
16+
name: Fusion Integration Tests
17+
18+
on:
19+
push:
20+
branches:
21+
- main
22+
pull_request:
23+
workflow_dispatch:
24+
25+
env:
26+
PYTHON_VERSION: "3.11"
27+
28+
jobs:
29+
run-tests:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
# Only Snowflake for now - add more adapters here as Fusion support expands
35+
adapter: [snowflake]
36+
37+
steps:
38+
- name: "Checkout ${{ github.event.repository }}"
39+
uses: actions/checkout@v4
40+
41+
- name: "Set up Python ${{ env.PYTHON_VERSION }}"
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ env.PYTHON_VERSION }}
45+
46+
- name: "Install dbt Fusion"
47+
run: |
48+
curl -fsSL https://public.cdn.getdbt.com/fs/install/install.sh | sh
49+
echo "$HOME/.local/bin" >> $GITHUB_PATH
50+
51+
- name: "Verify Fusion installation"
52+
run: |
53+
dbt --version
54+
55+
- name: "Install tox"
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install tox
59+
60+
- name: "Run Fusion integration tests on ${{ matrix.adapter }}"
61+
run: |
62+
tox -e dbt_integration_fusion_${{ matrix.adapter }}
63+
env:
64+
# snowflake
65+
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
66+
SNOWFLAKE_USER: ${{ vars.SNOWFLAKE_USER }}
67+
DBT_ENV_SECRET_SNOWFLAKE_PASS: ${{ secrets.SNOWFLAKE_PASS }}
68+
SNOWFLAKE_ROLE: ${{ vars.SNOWFLAKE_ROLE }}
69+
SNOWFLAKE_DATABASE: ${{ vars.SNOWFLAKE_DATABASE }}
70+
SNOWFLAKE_WAREHOUSE: ${{ vars.SNOWFLAKE_WAREHOUSE }}
71+
SNOWFLAKE_SCHEMA: "fusion_integration_tests_${{ matrix.adapter }}_${{ github.run_number }}"

integration_tests/dbt_project.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ seeds:
6363
+enabled: false
6464

6565
vars:
66+
# Set to true when running with dbt Fusion to disable tests that are not compatible
67+
deactivate_for_fusion: false
6668
# ensure integration tests run successfully when there are 0 of a given model type (extra)
6769
exclude_packages: ['exclude_package']
6870
exclude_paths_from_project: ["/to_exclude/","source_3.table_6"]

integration_tests/seeds/dag/dag_seeds.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ seeds:
9696
data_tests:
9797
- dbt_utils.equality:
9898
name: equality_fct_hard_coded_references
99+
# Fusion doesn't have access to raw SQL code, so it can't detect hard-coded references
100+
config:
101+
enabled: "{{ not var('deactivate_for_fusion', false) }}"
99102
arguments:
100103
compare_model: ref('fct_hard_coded_references')
101104
compare_columns:

integration_tests/seeds/docs/docs_seeds.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ seeds:
1414
- name: test_fct_documentation_coverage
1515
config:
1616
column_types:
17-
staging_documentation_coverage_pct: &float "{{ 'float' if target.type not in ['athena', 'databricks', 'duckdb','trino', 'spark'] else 'decimal(10,2)' }}"
17+
documentation_coverage_pct: &float "{{ 'float' if target.type not in ['athena', 'databricks', 'duckdb','trino', 'spark'] else 'decimal(10,2)' }}"
18+
staging_documentation_coverage_pct: *float
1819
intermediate_documentation_coverage_pct: *float
1920
marts_documentation_coverage_pct: *float
2021
other_documentation_coverage_pct: *float

integration_tests/seeds/tests/tests_seeds.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ seeds:
55
data_tests:
66
- dbt_utils.equality:
77
name: equality_fct_missing_primary_key_tests
8+
# Fusion has column_name empty for tests in the graph (issue #1243)
9+
config:
10+
enabled: "{{ not var('deactivate_for_fusion', false) }}"
811
arguments:
912
compare_model: ref('fct_missing_primary_key_tests')
1013
exclude_columns:
@@ -14,11 +17,12 @@ seeds:
1417
- name: test_fct_test_coverage
1518
config:
1619
column_types:
17-
test_coverage_pct: &float "{{ 'float' if target.type not in ['athena', 'trino'] else 'double' }}"
20+
test_coverage_pct: &float "{{ 'float' if target.type not in ['athena', 'trino', 'duckdb'] else 'double' }}"
1821
staging_test_coverage_pct: *float
1922
intermediate_test_coverage_pct: *float
2023
marts_test_coverage_pct: *float
2124
other_test_coverage_pct: *float
25+
test_to_model_ratio: *float
2226
data_tests:
2327
- dbt_utils.equality:
2428
name: equality_fct_test_coverage

macros/unpack/get_relationship_values.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@
3535

3636
{%- for parent in node.get('depends_on',{}).get('nodes',[]) -%}
3737

38-
{%- set values_line =
38+
{# Use attached_node to determine primary relationship for tests (works in both Core and Fusion) #}
39+
{# Fall back to loop.last for backwards compatibility if attached_node is not available #}
40+
{%- set is_primary = (parent == node.get('attached_node')) if node.get('attached_node') else loop.last -%}
41+
{%- set values_line =
3942
[
4043
"cast('" ~ node.unique_id ~ "' as " ~ dbt_project_evaluator.type_string_dpe() ~ ")",
4144
"cast('" ~ parent ~ "' as " ~ dbt_project_evaluator.type_string_dpe() ~ ")",
42-
"" ~ loop.last ~ "" if node.unique_id.split('.')[0] == 'test' else "FALSE"
45+
"" ~ is_primary ~ "" if node.unique_id.split('.')[0] == 'test' else "FALSE"
4346
]
4447
%}
4548

run_fusion_tests.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Run integration tests using dbt Fusion
4+
# Usage: ./run_fusion_tests.sh <target>
5+
# Note: --static-analysis=off is required for Fusion compatibility
6+
# Note: deactivate_for_fusion=true disables tests that are not compatible with Fusion
7+
8+
FUSION_VARS='{"deactivate_for_fusion": true}'
9+
10+
echo "Running Fusion tests for the first project"
11+
cd integration_tests
12+
dbt deps --target $1 || exit 1
13+
dbt build -x --target $1 --full-refresh --static-analysis=off --vars "$FUSION_VARS" || exit 1
14+
15+
echo "Running Fusion tests for the second project"
16+
cd ../integration_tests_2
17+
dbt deps --target $1 || exit 1
18+
dbt seed --full-refresh --target $1 --static-analysis=off --vars "$FUSION_VARS" || exit 1
19+
dbt run -x --target $1 --full-refresh --static-analysis=off --vars "$FUSION_VARS" || exit 1

tox.ini

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,17 @@ commands =
8181
bash ./run_tox_tests.sh duckdb
8282

8383
[testenv:dbt_integration_databricks]
84-
allowlist_externals =
84+
allowlist_externals =
85+
bash
86+
skip_install = true
87+
commands =
88+
bash ./run_tox_tests.sh databricks
89+
90+
# Fusion integration tests - uses --static-analysis=off flag
91+
# See .github/workflows/fusion.yml for the workflow that installs Fusion
92+
[testenv:dbt_integration_fusion_snowflake]
93+
allowlist_externals =
8594
bash
8695
skip_install = true
8796
commands =
88-
bash ./run_tox_tests.sh databricks
97+
bash ./run_fusion_tests.sh snowflake

0 commit comments

Comments
 (0)