Skip to content

Commit

Permalink
remove current_timestamp macro and obsolete functional tests (#694)
Browse files Browse the repository at this point in the history
* Correct link from README to the CONTRIBUTING guide. (#687)

* fix typo (#688)

Co-authored-by: Alex Malins <22991362+alexmalins@users.noreply.github.com>

* remove current_timestamp macro

* add recency test back

* fix recency

* fix recency

* update dev reqs

* update dev reqs

* fix recency.sql

* fix recency

* update dev-requirements

* Fix copy paste error on TestTypeString

* Remove specific branch reference for prerelease adapters

* Delete obsolete functional tests

* Remove functional test invocations from circle config

* Remove references to retired macros in integration tests

* Missed one

* I msut save my files I must save my files I must save my files

Co-authored-by: Liam O'Boyle <github@elyobo.net>
Co-authored-by: Alex Malins <github@alexmalins.com>
Co-authored-by: Alex Malins <22991362+alexmalins@users.noreply.github.com>
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
  • Loading branch information
5 people authored Oct 4, 2022
1 parent 369a2d0 commit 2a1e586
Show file tree
Hide file tree
Showing 23 changed files with 24 additions and 470 deletions.
12 changes: 0 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
steps:
- checkout
- run: pip install --pre dbt-postgres -r dev-requirements.txt
- run:
name: "Run Functional Tests - Postgres"
command: ./run_functional_test.sh postgres
- run:
name: "Run OG Tests - Postgres"
command: ./run_test.sh postgres
Expand All @@ -34,9 +31,6 @@ jobs:
steps:
- checkout
- run: pip install --pre dbt-redshift -r dev-requirements.txt
- run:
name: "Run Functional Tests - Redshift"
command: ./run_functional_test.sh redshift
- run:
name: "Run OG Tests - Redshift"
command: ./run_test.sh redshift
Expand All @@ -49,9 +43,6 @@ jobs:
steps:
- checkout
- run: pip install --pre dbt-snowflake -r dev-requirements.txt
- run:
name: "Run Functional Tests - Snowflake"
command: ./run_functional_test.sh snowflake
- run:
name: "Run OG Tests - Snowflake"
command: ./run_test.sh snowflake
Expand All @@ -69,9 +60,6 @@ jobs:
- run:
name: "Set up credentials"
command: echo $BIGQUERY_SERVICE_ACCOUNT_JSON > ${HOME}/bigquery-service-key.json
- run:
name: "Run Functional Tests - BigQuery"
command: ./run_functional_test.sh bigquery
- run:
name: "Run OG Tests - BigQuery"
command: ./run_test.sh bigquery
Expand Down
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Check [dbt Hub](https://hub.getdbt.com/dbt-labs/dbt_utils/latest/) for the lates
- [get_url_path](#get_url_path-source)

- [Cross-database macros](#cross-database-macros):
- [current_timestamp](#current_timestamp-source)
- [dateadd](#dateadd-source)
- [datediff](#datediff-source)
- [split_part](#split_part-source)
Expand Down Expand Up @@ -1194,18 +1193,6 @@ Note that most of these macros moved to dbt Core as of dbt_utils v0.9.0 and dbt
To access the version defined in dbt Core, remove the `dbt_utils.` prefix (see [https://docs.getdbt.com/reference/dbt-jinja-functions/cross-database-macros](https://docs.getdbt.com/reference/dbt-jinja-functions/cross-database-macros) for examples).
As highlighted below, some of the cross-database macros are still in the process of being deprecated.

#### current_timestamp ([source](macros/cross_db_utils/current_timestamp.sql))

*DEPRECATED: This macro is deprecated and will be removed in a future version of the package, once equivalent functionality is implemented in dbt Core.*

This macro returns the current timestamp.

**Usage:**

```
{{ dbt_utils.current_timestamp() }}
```

#### dateadd ([source](macros/cross_db_utils/dateadd.sql))

*DEPRECATED: This macro is now provided in dbt Core. It is no longer available in dbt_utils and backwards compatibility will be removed in a future version of the package.*
Expand Down Expand Up @@ -1509,7 +1496,7 @@ A useful workaround is to change the above post-hook to:
### Reporting bugs and contributing code
- Want to report a bug or request a feature? Let us know in the `#package-ecosystem` channel on [Slack](http://community.getdbt.com/), or open [an issue](https://github.com/dbt-labs/dbt-utils/issues/new)
- Want to help us build dbt-utils? Check out the [Contributing Guide](https://github.com/dbt-utils/dbt-core/blob/HEAD/CONTRIBUTING.md)
- Want to help us build dbt-utils? Check out the [Contributing Guide](https://github.com/dbt-labs/dbt-utils/blob/main/CONTRIBUTING.md)
- **TL;DR** Open a Pull Request with 1) your changes, 2) updated documentation for the `README.md` file, and 3) a working integration test.

----
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/models/generic_tests/test_recency.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
select
1 as col1,
2 as col2,
{{ dbt_utils.date_trunc('day', dbt_utils.current_timestamp()) }} as today
{{ date_trunc('day', current_timestamp()) }} as today

{% else %}

select
1 as col1,
2 as col2,
cast({{ dbt_utils.date_trunc('day', dbt_utils.current_timestamp()) }} as datetime) as today
cast({{ date_trunc('day', current_timestamp()) }} as datetime) as today

{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final as (
lon2='lon_2',
unit='km'
)
}} as {{ dbt_utils.type_numeric() }}
}} as {{ type_numeric() }}
) as actual
from data
)
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/models/geo/test_haversine_distance_mi.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final as (
lon2='lon_2',
unit='mi'
)
}} as {{ dbt_utils.type_numeric() }}
}} as {{ type_numeric() }}
) as actual
from data

Expand All @@ -29,7 +29,7 @@ final as (
lat2='lat_2',
lon2='lon_2',
)
}} as {{ dbt_utils.type_numeric() }}
}} as {{ type_numeric() }}
) as actual
from data
)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/models/sql/test_get_column_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from {{ ref('data_get_column_values') }}
select
{% for val in column_values -%}

{{dbt_utils.safe_cast("sum(case when field = '" ~ val ~ "' then 1 else 0 end)", dbt_utils.type_string()) }} as count_{{ val }}
{{ safe_cast("sum(case when field = '" ~ val ~ "' then 1 else 0 end)", type_string()) }} as count_{{ val }}
{%- if not loop.last %},{% endif -%}

{%- endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

-- Create a relation using the values
{% for val in column_values -%}
select {{ dbt_utils.string_literal(val) }} as field {% if not loop.last %}union all{% endif %}
select {{ string_literal(val) }} as field {% if not loop.last %}union all{% endif %}
{% endfor %}
4 changes: 2 additions & 2 deletions integration_tests/models/sql/test_groupby.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ with test_data as (

select

{{ dbt_utils.safe_cast("'a'", dbt_utils.type_string() )}} as column_1,
{{ dbt_utils.safe_cast("'b'", dbt_utils.type_string() )}} as column_2
{{ safe_cast("'a'", type_string() )}} as column_1,
{{ safe_cast("'b'", type_string() )}} as column_2

),

Expand Down
12 changes: 6 additions & 6 deletions integration_tests/models/sql/test_nullcheck_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ from nulled

select

{{ dbt_utils.safe_cast('field_1',
dbt_utils.type_string()
{{ safe_cast('field_1',
type_string()
)}} as field_1,

{{ dbt_utils.safe_cast('field_2',
dbt_utils.type_string()
{{ safe_cast('field_2',
type_string()
)}} as field_2,

{{ dbt_utils.safe_cast('field_3',
dbt_utils.type_string()
{{ safe_cast('field_3',
type_string()
)}} as field_3

from nulled
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/models/sql/test_unpivot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ select
from (
{{ dbt_utils.unpivot(
relation=ref('data_unpivot'),
cast_to=dbt_utils.type_string(),
cast_to=type_string(),
exclude=exclude,
remove=['name'],
field_name='prop',
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/models/sql/test_unpivot_bool.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ select
from (
{{ dbt_utils.unpivot(
relation=ref('data_unpivot_bool'),
cast_to=dbt_utils.type_string(),
cast_to=type_string(),
exclude=exclude,
field_name='prop',
value_name='val'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
{% set column_values = dbt_utils.get_column_values(ref('data_get_column_values_dropped'), 'field', default=['y', 'z'], order_by="field") %}

with expected as (
select {{ dbt_utils.safe_cast("'y'", dbt_utils.type_string()) }} as expected_column_value union all
select {{ dbt_utils.safe_cast("'z'", dbt_utils.type_string()) }} as expected_column_value
select {{ safe_cast("'y'", type_string()) }} as expected_column_value union all
select {{ safe_cast("'z'", type_string()) }} as expected_column_value
),

actual as (

{% for val in column_values %}
select {{ dbt_utils.safe_cast("'" ~ val ~ "'", dbt_utils.type_string()) }} as actual_column_value
select {{ safe_cast("'" ~ val ~ "'", type_string()) }} as actual_column_value
{% if not loop.last %}
union all
{% endif %}
Expand Down
40 changes: 0 additions & 40 deletions macros/cross_db_utils/current_timestamp.sql

This file was deleted.

2 changes: 1 addition & 1 deletion macros/generic_tests/mutually_exclusive_ranges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ with window_functions as (

calc as (
-- We want to return records where one of our assumptions fails, so we'll use
-- the `not` function with `and` statements so we can write our assumptions nore cleanly
-- the `not` function with `and` statements so we can write our assumptions more cleanly
select
*,

Expand Down
2 changes: 1 addition & 1 deletion macros/generic_tests/recency.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% macro default__test_recency(model, field, datepart, interval, group_by_columns) %}

{% set threshold = dbt_utils.dateadd(datepart, interval * -1, dbt_utils.current_timestamp()) %}
{% set threshold = dateadd(datepart, interval * -1, current_timestamp()) %}
{% if group_by_columns|length() > 0 %}
{% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}
{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}
Expand Down
Loading

0 comments on commit 2a1e586

Please sign in to comment.