Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin committed Jan 4, 2024
1 parent c0084bd commit 87dddd9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
36 changes: 25 additions & 11 deletions .github/workflows/dbt_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ jobs:

- name: load test data
run: dbt seed --target ${DBT_TARGET}

- name: dbt test macros
run: dbt test --target ${DBT_TARGET}

- name: Create seed tests
run: bash tests/create_seeds_tests_yml.sh

- name: dbt test
run: dbt test --target ${DBT_TARGET} --exclude "*recency*"
- name: dbt test seeds
run: dbt test --target ${DBT_TARGET} --select config.materialized:seed --exclude "dbt_utils_recency*"

test-postgres:
name: Test on Postgres
Expand Down Expand Up @@ -71,11 +74,14 @@ jobs:
- name: load test data
run: dbt seed --target ${DBT_TARGET}

- name: dbt test macros
run: dbt test --target ${DBT_TARGET}

- name: Create seed tests
run: bash tests/create_seeds_tests_yml.sh

- name: dbt test
run: dbt test --target ${DBT_TARGET} --exclude "*recency*"
- name: dbt test seeds
run: dbt test --target ${DBT_TARGET} --select config.materialized:seed --exclude "dbt_utils_recency*"

test-snowflake:
name: Test on Snowflake
Expand All @@ -99,11 +105,14 @@ jobs:
- name: load test data
run: dbt seed --target ${DBT_TARGET}

- name: dbt test macros
run: dbt test --target ${DBT_TARGET}

- name: Create seed tests
run: bash tests/create_seeds_tests_yml.sh

- name: dbt test
run: dbt test --target ${DBT_TARGET} --exclude "*recency*"
- name: dbt test seeds
run: dbt test --target ${DBT_TARGET} --select config.materialized:seed --exclude "dbt_utils_recency*"

test-redshift:
name: Test on RedShift
Expand All @@ -127,11 +136,14 @@ jobs:
- name: load test data
run: dbt seed --target ${DBT_TARGET}

- name: dbt test macros
run: dbt test --target ${DBT_TARGET}

- name: Create seed tests
run: bash tests/create_seeds_tests_yml.sh

- name: dbt test
run: dbt test --target ${DBT_TARGET} --exclude "*recency*"
- name: dbt test seeds
run: dbt test --target ${DBT_TARGET} --select config.materialized:seed --exclude "dbt_utils_recency*"

test-bigquery:
name: Test on BigQuery
Expand Down Expand Up @@ -164,14 +176,16 @@ jobs:
- name: load test data
run: dbt seed --target ${DBT_TARGET} -s users

- name: dbt test macros
run: dbt test --target ${DBT_TARGET}

- name: Create seed tests
run: |
dbt compile --target ${DBT_TARGET} -q \
--inline "{{ testgen.get_test_suggestions(ref('users'), resource_type='seeds', column_config={'quote': true, 'tags': ['dataset-users']} ) }}" \
> seeds/users_test_suggestions.yml
- name: dbt test
run: dbt test --target ${DBT_TARGET} -s tag:dataset-users

- name: dbt test seeds
run: dbt test --target ${DBT_TARGET} --select config.materialized:seed --exclude "dbt_utils_recency*"


2 changes: 1 addition & 1 deletion integration_tests/seeds/sp500_daily.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
date,close,open,high,low
day,close,open,high,low
2024-01-02,4742.83,4745.20,4754.33,4722.67
2023-12-29,4769.83,4782.88,4788.43,4751.99
2023-12-28,4783.35,4786.44,4793.30,4780.98
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/seeds/sp500_monthly.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
date,sp500,dividend,earnings,consumer_price_index,long_interest_rate,real_price,real_dividend,real_earnings,pe10
month,sp500,dividend,earnings,consumer_price_index,long_interest_rate,real_price,real_dividend,real_earnings,pe10
1871-01-01,4.44,0.26,0.4,12.46,5.32,89.0,5.21,8.02,
1871-02-01,4.5,0.26,0.4,12.84,5.32,87.53,5.06,7.78,
1871-03-01,4.61,0.26,0.4,13.03,5.33,88.36,4.98,7.67,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ models:
- name: sp500_daily
tests:
- dbt_utils.recency:
field: date
field: day
datepart: day
interval: 2
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ models:
- name: sp500_monthly
tests:
- dbt_utils.recency:
field: Date
field: month
datepart: day
interval: 31
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ models:
- name: sp500_daily
tests:
- dbt_utils.recency:
field: date
field: day
datepart: day
interval: 2
columns:
- name: date
- name: day
tests:
- unique
- not_null
Expand Down
2 changes: 1 addition & 1 deletion macros/test_generation/get_recency_test_suggestions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{{ loop.index }} AS ordering
FROM (
SELECT
{{ dbt.datediff("LAG(date, 1) OVER(ORDER BY " ~ adapter.quote(col.column) ~ ")", adapter.quote(col.column), "minute") }} AS minutes_diff
{{ dbt.datediff("LAG(" ~ adapter.quote(col.column) ~ ", 1) OVER(ORDER BY " ~ adapter.quote(col.column) ~ ")", adapter.quote(col.column), "minute") }} AS minutes_diff
FROM base
) t2
WHERE minutes_diff <> 0
Expand Down

0 comments on commit 87dddd9

Please sign in to comment.