Skip to content

Commit 1c2f80e

Browse files
Merge pull request #2 from AidanHarveyNelson/feature/add-complete-integration-tests
Stashing integration tests
2 parents 07ae2ef + fade249 commit 1c2f80e

15 files changed

Lines changed: 98 additions & 154 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# **what?**
2-
# Run tests for dbt-external-tables against supported adapters
2+
# Run tests for dbt-streams-tasks against supported adapters
33

44
# **why?**
5-
# To ensure that dbt-external-tables works as expected with all supported adapters
5+
# To ensure that dbt-streams-tasks works as expected with all supported adapters
66

77
# **when?**
88
# On every PR, and every push to main and when manually triggered
@@ -20,34 +20,13 @@ jobs:
2020
run-tests:
2121
uses: dbt-labs/dbt-package-testing/.github/workflows/run_tox.yml@v1
2222
with:
23-
# redshift
24-
REDSHIFT_HOST: ${{ vars.REDSHIFT_HOST }}
25-
REDSHIFT_USER: ${{ vars.REDSHIFT_USER }}
26-
REDSHIFT_PORT: ${{ vars.REDSHIFT_PORT }}
27-
REDSHIFT_DATABASE: ${{ vars.REDSHIFT_DATABASE }}
28-
REDSHIFT_SCHEMA: "integration_tests_redshift_${{ github.run_number }}"
2923
# snowflake
3024
SNOWFLAKE_USER: ${{ vars.SNOWFLAKE_USER }}
3125
SNOWFLAKE_WAREHOUSE: ${{ vars.SNOWFLAKE_WAREHOUSE }}
3226
SNOWFLAKE_ROLE: ${{ vars.SNOWFLAKE_ROLE }}
3327
SNOWFLAKE_DATABASE: ${{ vars.SNOWFLAKE_DATABASE }}
3428
SNOWFLAKE_SCHEMA: "integration_tests_snowflake_${{ github.run_number }}"
35-
# bigquery
36-
BIGQUERY_PROJECT: ${{ vars.BIGQUERY_PROJECT }}
37-
BIGQUERY_SCHEMA: "integration_tests_bigquery_${{ github.run_number }}"
38-
# synapse
39-
# temporarily removed until we can get the cluster hooked up to the blob correctly
40-
# SYNAPSE_DRIVER: ${{ vars.SYNAPSE_DRIVER }}
41-
# SYNAPSE_HOST: ${{ vars.SYNAPSE_HOST }}
42-
# SYNAPSE_PORT: ${{ vars.SYNAPSE_PORT }}
43-
# SYNAPSE_DATABASE: ${{ vars.SYNAPSE_DATABASE }}
44-
# SYNAPSE_AUTHENTICATION: ${{ vars.SYNAPSE_AUTHENTICATION }}
45-
# SYNAPSE_TENANT_ID: ${{ vars.SYNAPSE_TENANT_ID }}
46-
# SYNAPSE_CLIENT_ID: ${{ vars.SYNAPSE_CLIENT_ID }}
4729

4830
secrets:
49-
DBT_ENV_SECRET_REDSHIFT_PASS: ${{ secrets.DBT_ENV_SECRET_REDSHIFT_PASS }}
5031
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
5132
DBT_ENV_SECRET_SNOWFLAKE_PASS: ${{ secrets.DBT_ENV_SECRET_SNOWFLAKE_PASS }}
52-
BIGQUERY_KEYFILE_JSON: ${{ secrets.BIGQUERY_KEYFILE_JSON }}
53-
DBT_ENV_SECRET_SYNAPSE_CLIENT_SECRET: ${{ secrets.DBT_ENV_SECRET_SYNAPSE_CLIENT_SECRET }}

.github/workflows/integration_tests.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

CHANGLOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
# Changelog
2+
3+
## v0.0.2 (TBA)
4+
5+
- Feature: Expanded integration tests to cover all use cases
6+
7+
8+
## v0.0.1 (2025-09-03)
9+
10+
- Feature: Initial implementation logic

dbt_project.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
name: 'audit_helper'
2-
version: '0.4.0'
1+
name: 'dbt_snowflake_streams_tasks'
2+
version: '0.0.1'
33
config-version: 2
4-
5-
require-dbt-version: [">=1.2.0", "<2.0.0"]
6-
7-
target-path: "target"
8-
clean-targets: ["target", "dbt_packages"]
4+
require-dbt-version: [">=1.0.0", "<2.0.0"]
95
macro-paths: ["macros"]
10-
log-path: "logs"

integration_tests/macros/prep_structure.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,27 @@
1616
create or replace table {{ table }} (
1717
id integer,
1818
data string
19-
);
19+
)
20+
CHANGE_TRACKING = TRUE
21+
;
2022
commit;
2123
{% endset %}
2224

2325
{% do log('Creating testing table ' ~ table, info = true) %}
2426
{% do run_query(create_testing_table_sql) %}
2527
{% endfor %}
2628

29+
30+
{% set test_table = [target.database, target.schema, 'testing_ref']|join('.') %}
31+
32+
{% set insert_data_sql %}
33+
begin;
34+
insert into {{test_table}} values (1, 'test data');
35+
commit;
36+
{% endset %}
37+
38+
{% do log('Inserting data into testing table ' ~ test_table, info = true) %}
39+
{% do run_query(insert_data_sql) %}
40+
41+
2742
{% endmacro %}

integration_tests/models/customers/_models.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ models:
1717
name: "transform_from_stream_test"
1818
description: "Task for the customers table"
1919
when: "SYSTEM$STREAM_HAS_DATA('stream_from_source_test')"
20-
schedule: "5 MINUTES"
20+
schedule: "1 MINUTES"
2121
columns:
2222
- name: id
23+
24+
- name: stream_from_ref
25+
config:
26+
materialized: stream_task
27+
unique_key:
28+
- id
29+
stream:
30+
name: "stream_from_ref_test"
31+
description: "Stream for the customers table"
32+
tags:
33+
- customers
34+
copy_grants: True
35+
append_only: False
36+
task:
37+
name: "transform_from_ref_test"
38+
description: "Task for the customers table"
39+
when: "SYSTEM$STREAM_HAS_DATA('stream_from_ref_test')"
40+
schedule: "1 MINUTES"

integration_tests/models/customers/customers.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
select *
2+
from {{ dbt_snowflake_streams_tasks.stream_ref('view_on_source') }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{
2+
config(
3+
materialized = 'view',
4+
)
5+
}}
6+
7+
select *
8+
from {{ source('customers', 'testing_ref') }}

macros/helpers/create_stream.sql

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
{%- macro create_stream(source_table) -%}
22
{%- do log('Source Table is: ' ~ source_table, info = true) -%}
33
{%- set name = config.require('stream').name -%}
4-
{%- do log('Creating Stream: ' ~ name, info = true) -%}
5-
{%- set args_sql -%}
6-
APPEND_ONLY = {{ config.get('stream').append_only|upper or 'TRUE' }}
7-
COMMENT = '{{ config.get('stream').description or '' }}'
8-
{{- "COPY GRANTS" ~ config.get('stream').copy_grants if config.get('stream').copy_grants else '' -}}
9-
{%- endset -%}
4+
105
{%- set run_sql -%}
11-
CREATE OR REPLACE STREAM {{ name }} ON TABLE {{ source_table }}
12-
{{ args_sql }}
6+
CREATE OR REPLACE STREAM {{ name }}
7+
{{ "COPY GRANTS" if config.get('stream').copy_grants else '' }}
8+
{# To-Do Add Tag Config#}
139
{%- endset -%}
10+
11+
{% if source_table.is_view %}
12+
{%- set run_sql -%}
13+
{{ run_sql ~ " ON VIEW " ~ source_table }}
14+
COMMENT = '{{ config.get('stream').description or '' }}'
15+
APPEND_ONLY = {{ config.get('stream').append_only|upper or 'TRUE' }}
16+
SHOW_INITIAL_ROWS = {{ config.get('stream').show_initial_rows|upper or 'TRUE' }}
17+
{%- endset -%}
18+
{% elif source_table.is_table %}
19+
{%- set run_sql -%}
20+
{{ run_sql ~ " ON TABLE " ~ source_table }}
21+
COMMENT = '{{ config.get('stream').description or '' }}'
22+
APPEND_ONLY = {{ config.get('stream').append_only|upper or 'TRUE' }}
23+
SHOW_INITIAL_ROWS = {{ config.get('stream').show_initial_rows|upper or 'TRUE' }}
24+
{%- endset -%}
25+
{%- else -%}
26+
{%- do exceptions.raise_compiler_error("Invalid materialization type provided to stream macro. Use 'view' or 'table'. Object passed in is " ~ source_table ~ " with type: " ~ source_table.type) -%}
27+
{%- endif -%}
28+
{%- do log('Creating Stream: ' ~ name, info = true) -%}
1429
{{ run_sql }}
1530
{%- endmacro -%}

0 commit comments

Comments
 (0)