Skip to content

Commit

Permalink
consolidate timestamp macros (#480)
Browse files Browse the repository at this point in the history
* add mypy ignore to column, connections and init

* consolidate timestamp macros

* add changie

* Update Features-20220926-123609.yaml

* add backcompat to test fixture

* remove current_timestamp_in_utc

* add expected_sql

* remove backcompat from test_timestamps.py

* update dev-requirements

* Update change log body

* lower case timestamps
  • Loading branch information
colin-rogers-dbt authored Oct 3, 2022
1 parent 0cb9582 commit b65e4f3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20220926-123609.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-26T12:36:09.319981-07:00
custom:
Author: colin-rogers-dbt
Issue: "483"
PR: "480"
4 changes: 0 additions & 4 deletions dbt/include/spark/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@
{{ return(load_result('list_schemas').table) }}
{% endmacro %}

{% macro spark__current_timestamp() -%}
current_timestamp()
{%- endmacro %}

{% macro spark__rename_relation(from_relation, to_relation) -%}
{% call statement('rename_relation') -%}
{% if not from_relation.type %}
Expand Down
3 changes: 3 additions & 0 deletions dbt/include/spark/macros/utils/timestamps.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro spark__current_timestamp() -%}
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 TestCurrentTimestampSpark(BaseCurrentTimestamps):
@pytest.fixture(scope="class")
def models(self):
return {"get_current_timestamp.sql": "select {{ current_timestamp() }} as current_timestamp"}

@pytest.fixture(scope="class")
def expected_schema(self):
return {
"current_timestamp": "timestamp"
}

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

0 comments on commit b65e4f3

Please sign in to comment.