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

Cross-database date macro #1030

Merged
merged 6 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240501-151904.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Cross-database `date` macro
time: 2024-05-01T15:19:04.822157-06:00
custom:
Author: dbeatty10
Issue: 1031
5 changes: 5 additions & 0 deletions dbt/include/spark/macros/utils/date.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% macro spark__date(year, month, day) -%}
{%- set dt = modules.datetime.date(year, month, day) -%}
{%- set iso_8601_formatted_date = dt.strftime('%Y-%m-%d') -%}
to_date('{{ iso_8601_formatted_date }}', 'yyyy-MM-dd')
{%- endmacro %}
5 changes: 5 additions & 0 deletions tests/functional/adapter/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dbt.tests.adapter.utils.test_cast_bool_to_text import BaseCastBoolToText
from dbt.tests.adapter.utils.test_concat import BaseConcat
from dbt.tests.adapter.utils.test_current_timestamp import BaseCurrentTimestampNaive
from dbt.tests.adapter.utils.test_date import BaseDate
from dbt.tests.adapter.utils.test_dateadd import BaseDateAdd
from dbt.tests.adapter.utils.test_datediff import BaseDateDiff
from dbt.tests.adapter.utils.test_date_trunc import BaseDateTrunc
Expand Down Expand Up @@ -80,6 +81,10 @@ class TestCurrentTimestamp(BaseCurrentTimestampNaive):
pass


class TestDate(BaseDate):
pass


class TestDateAdd(BaseDateAdd):
pass

Expand Down
Loading