-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* consolidate timestamp macros * add testing changes * deleting extra timestamps.sql * changie entry * fix backcompat * Update Breaking Changes-20220923-112314.yaml * Update dev-requirements.txt * remove current_timestamp_in_utc * fix backcompat * change test import * fix BaseCurrentTimestamps import * update dev-requirements * Update change log body * fix changie log
- Loading branch information
1 parent
c69e213
commit 2ef59aa
Showing
4 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Feature | ||
body: Migrate dbt-utils current_timestamp macros into core + adapters | ||
time: 2022-09-23T11:23:14.312738-07:00 | ||
custom: | ||
Author: colin-rogers-dbt | ||
Issue: "276" | ||
PR: "273" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% macro snowflake__current_timestamp() -%} | ||
convert_timezone('UTC', current_timestamp()) | ||
{%- endmacro %} | ||
|
||
{% macro snowflake__snapshot_string_as_time(timestamp) -%} | ||
{%- set result = "to_timestamp_ntz('" ~ timestamp ~ "')" -%} | ||
{{ return(result) }} | ||
{%- endmacro %} | ||
|
||
{% macro snowflake__snapshot_get_time() -%} | ||
to_timestamp_ntz({{ current_timestamp() }}) | ||
{%- endmacro %} | ||
|
||
{% macro snowflake__current_timestamp_backcompat() %} | ||
current_timestamp::{{ type_timestamp() }} | ||
{% endmacro %} | ||
|
||
{% macro snowflake__current_timestamp_in_utc_backcompat() %} | ||
convert_timezone('UTC', {{ snowflake__current_timestamp_backcompat() }})::{{ type_timestamp() }} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import imp | ||
import pytest | ||
from dbt.tests.adapter.utils.test_timestamps import BaseCurrentTimestamps | ||
|
||
_MODEL_CURRENT_TIMESTAMP = """ | ||
SELECT {{current_timestamp()}} as current_timestamp, | ||
{{current_timestamp_in_utc_backcompat()}} as current_timestamp_in_utc_backcompat, | ||
{{current_timestamp_backcompat()}} as current_timestamp_backcompat | ||
""" | ||
|
||
|
||
class TestCurrentTimestampSnowflake(BaseCurrentTimestamps): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"get_current_timestamp.sql": _MODEL_CURRENT_TIMESTAMP} | ||
|
||
@pytest.fixture(scope="class") | ||
def expected_schema(self): | ||
return { | ||
"CURRENT_TIMESTAMP": "TIMESTAMP_TZ", | ||
"CURRENT_TIMESTAMP_IN_UTC_BACKCOMPAT": "TIMESTAMP_NTZ", | ||
"CURRENT_TIMESTAMP_BACKCOMPAT": "TIMESTAMP_NTZ", | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def expected_sql(self): | ||
return """ | ||
select convert_timezone('UTC', current_timestamp()) as current_timestamp, | ||
convert_timezone('UTC', current_timestamp::TIMESTAMP)::TIMESTAMP as current_timestamp_in_utc_backcompat, | ||
current_timestamp::TIMESTAMP as current_timestamp_backcompat | ||
""" |