diff --git a/.changes/unreleased/Features-20220926-123609.yaml b/.changes/unreleased/Features-20220926-123609.yaml new file mode 100644 index 000000000..b80b3730d --- /dev/null +++ b/.changes/unreleased/Features-20220926-123609.yaml @@ -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" diff --git a/dbt/include/spark/macros/adapters.sql b/dbt/include/spark/macros/adapters.sql index 88190cc04..abc7a0ba3 100644 --- a/dbt/include/spark/macros/adapters.sql +++ b/dbt/include/spark/macros/adapters.sql @@ -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 %} diff --git a/dbt/include/spark/macros/utils/timestamps.sql b/dbt/include/spark/macros/utils/timestamps.sql new file mode 100644 index 000000000..68d6f6884 --- /dev/null +++ b/dbt/include/spark/macros/utils/timestamps.sql @@ -0,0 +1,3 @@ +{% macro spark__current_timestamp() -%} + current_timestamp() +{%- endmacro %} diff --git a/tests/functional/adapter/utils/test_timestamps.py b/tests/functional/adapter/utils/test_timestamps.py new file mode 100644 index 000000000..8507c0a6b --- /dev/null +++ b/tests/functional/adapter/utils/test_timestamps.py @@ -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"""