Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consolidate timestamps #323

Merged
merged 22 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7be3a27
update retry settings
colin-rogers-dbt Sep 15, 2022
4fb655c
Merge branch 'main' into increaseMaxRetryDelay
colin-rogers-dbt Sep 15, 2022
ab1a7e2
changelog entry
colin-rogers-dbt Sep 15, 2022
d7cf197
consolidate timestamps
colin-rogers-dbt Sep 26, 2022
ee09228
Merge branch 'main' into consolidateTimestampMacros
colin-rogers-dbt Sep 26, 2022
efdc510
add changie
colin-rogers-dbt Sep 26, 2022
9483fba
whitespace fix
colin-rogers-dbt Sep 26, 2022
570561b
fix macro name
colin-rogers-dbt Sep 26, 2022
bbe14ae
update expected test fixture
colin-rogers-dbt Sep 26, 2022
c6af18f
Merge branch 'main' into consolidateTimestampMacros
colin-rogers-dbt Sep 26, 2022
ba288cb
Update Features-20220926-105700.yaml
colin-rogers-dbt Sep 26, 2022
057ce0e
add backcompat to test fixture
colin-rogers-dbt Sep 27, 2022
bab49a4
Merge branch 'consolidateTimestampMacros' of https://github.com/dbt-l…
colin-rogers-dbt Sep 27, 2022
e7baaae
Merge branch 'main' into consolidateTimestampMacros
colin-rogers-dbt Sep 27, 2022
6fa064b
Merge branch 'main' into consolidateTimestampMacros
colin-rogers-dbt Sep 28, 2022
241cf60
Merge branch 'main' into consolidateTimestampMacros
colin-rogers-dbt Sep 29, 2022
0f973e3
Merge branch 'consolidateTimestampMacros' of https://github.com/dbt-l…
colin-rogers-dbt Sep 29, 2022
60afae9
add backcompat
colin-rogers-dbt Sep 30, 2022
6667247
update dev-requirements
colin-rogers-dbt Sep 30, 2022
4bf2b33
Update change log body
colin-rogers-dbt Sep 30, 2022
6f1919f
update test class name
colin-rogers-dbt Sep 30, 2022
867117b
lowercase timestamps
colin-rogers-dbt Sep 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"""