Skip to content

Commit

Permalink
consolidate timestamps (#323) (#334)
Browse files Browse the repository at this point in the history
* update retry settings

* changelog entry

* consolidate timestamps

* add changie

* whitespace fix

* fix macro name

* update expected test fixture

* Update Features-20220926-105700.yaml

* add backcompat to test fixture

* add backcompat

* update dev-requirements

* Update change log body

* update test class name

* lowercase timestamps

(cherry picked from commit 86d5dbe)

Co-authored-by: colin-rogers-dbt <[email protected]>
  • Loading branch information
github-actions[bot] and colin-rogers-dbt authored Oct 3, 2022
1 parent bc85204 commit 48b043e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20220926-105700.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: Migrate dbt-utils current_timestamp macros into core + adapters
time: 2022-09-26T10:57:00.942765-07:00
custom:
Author: colin-rogers-dbt
Issue: "324"
PR: "323"
11 changes: 0 additions & 11 deletions dbt/include/bigquery/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,6 @@
{%- endmacro %}


{% macro bigquery__current_timestamp() -%}
CURRENT_TIMESTAMP()
{%- endmacro %}


{% macro bigquery__snapshot_string_as_time(timestamp) -%}
{%- set result = 'TIMESTAMP("' ~ timestamp ~ '")' -%}
{{ return(result) }}
{%- endmacro %}


{% macro bigquery__list_schemas(database) -%}
{{ return(adapter.list_schemas(database)) }}
{% endmacro %}
Expand Down
12 changes: 12 additions & 0 deletions dbt/include/bigquery/macros/utils/timestamps.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% macro bigquery__current_timestamp() -%}
current_timestamp()
{%- endmacro %}

{% macro bigquery__snapshot_string_as_time(timestamp) -%}
{%- set result = 'TIMESTAMP("' ~ timestamp ~ '")' -%}
{{ return(result) }}
{%- endmacro %}

{% macro bigquery__current_timestamp_backcompat() -%}
current_timestamp
{%- endmacro %}
18 changes: 18 additions & 0 deletions tests/functional/adapter/utils/test_timestamps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest
from dbt.tests.adapter.utils.test_timestamps import BaseCurrentTimestamps


class TestCurrentTimestampBigQuery(BaseCurrentTimestamps):
@pytest.fixture(scope="class")
def expected_schema(self):
return {
"current_timestamp": "TIMESTAMP",
"current_timestamp_in_utc_backcompat": "TIMESTAMP",
"current_timestamp_backcompat": "TIMESTAMP",
}

@pytest.fixture(scope="class")
def expected_sql(self):
return """select current_timestamp() as current_timestamp,
current_timestamp as current_timestamp_in_utc_backcompat,
current_timestamp as current_timestamp_backcompat"""

0 comments on commit 48b043e

Please sign in to comment.