dbt-msft / tsql-utils

dbt-utils for the dbt-msft family of packages
MIT License
25 stars 25 forks source link

mono-start and mono-pause unless fail #45

Closed dataders closed 3 years ago

dataders commented 3 years ago

save money. only turn on the Synapse db when Circle CI needs to run. Problem is how to only resume and pause once. This PR addresses that.

dataders commented 3 years ago

@clausherther can you help me understand why this expression is now false for 1/2 rows after the two recent PRs you merged? week_of_year = {{ dbt_date.week_of_year('date_day') }}" which I think is the corresponding true statement based on this test name result. dbt_utils_expression_is_true_test_dates_week_of_year_dbt_date_week_of_year_date_day_

I saw the new get_test_dates() but thought it only made changes to how how iso_week_of_year() works... or maybe the test failing here does have to do with iso_week_year? I'm confused -- help please!

Completed with 1 error and 0 warnings:

Failure in test dbt_utils_expression_is_true_test_dates_week_of_year_dbt_date_week_of_year_date_day_ (models/test_dates.yml)
  Got 1 result, expected 0.

  compiled SQL at target/compiled/dbt_date_integration_tests/models/test_dates.yml/schema_test/dbt_utils_expression_is_true_test_dates_13f7b863f7daf107edd9fbb8db9ccb79.sql

Done. PASS=13 WARN=0 ERROR=1 SKIP=0 TOTAL=14
clausherther commented 3 years ago

I made it easier to implement platform-specific date test data. For example, on Snowflake both week_of_year and iso_week_of_year show the iso week in snowflake__get_test_dates since that's the default on my Snowflake test instance. If your SQL server instance does that same, I think you can just shim your own version of get_test_dates to make this for SQL Server maybe? For example: https://github.com/calogica/presto-utils/blob/main/integration_tests/dbt_date/macros/get_test_dates.sql

Those two test dates belong to the same Sunday week, but different Monday weeks. On most platforms I've tested against that should be Sunday week 48. But I've seen things like Google Sheets call this week 49 for both, so maybe that's what SQL Server is returning? Dates and weeks are the worst cross platform...

dataders commented 3 years ago

@clausherther thanks so much for getting back to me.

What's bizarre to me is that:

  1. all tests were passing last week, and
  2. the test that is failing isn't about the iso_week_of_year() macro which I know changed recently, rather the week_of year() macro which didn't change. Additionally, the week_of_year row values in get_test_dates() didn't change compared to last week's version they've always been 48.

So what did change?