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

[Epic] Cross-database date macro #10075

Open
13 of 14 tasks
dbeatty10 opened this issue May 1, 2024 · 0 comments
Open
13 of 14 tasks

[Epic] Cross-database date macro #10075

dbeatty10 opened this issue May 1, 2024 · 0 comments

Comments

@dbeatty10
Copy link
Contributor

dbeatty10 commented May 1, 2024

This epic comprises the changes across dbt Labs repos necessary to implement a cross-database date macro as described in dbt-labs/dbt-adapters#192.

Implementation

There is no equivalent function specified in ISO/IEC 9075 (the SQL standard), so there is not a natural adapter-agnostic implementation from them.

However, many database vendors support a to_date function with syntax similar to the following:

to_date('{{ iso_8601_formatted_date }}', 'YYYY-MM-DD')

So we can utilize that as the base implementation and adapters can customize as-needed.

Utility

This function is also generally useful anytime someone wants to generate SQL to create an scalar DATE value by supplying an explicit year, month, day combo.

An expected use is supplying a start and end date to dbt.date_spine.

For example, #8825 describes how we'd like to automatically create a metricflow_time_spine model if the project defines any semantic objects, and that relies upon being able to do a cross-database dbt.date_spine given an explicit start and end date.

dbt-adapters

  1. enhancement refinement user docs
    dbeatty10
  2. cla:yes user docs

dbt-postgres

  1. cla:yes

dbt-redshift

  1. cla:yes

dbt-snowflake

  1. cla:yes

dbt-bigquery

  1. cla:yes

dbt-spark

  1. cla:yes

Documentation

  1. content dbt Core dbt-core v1.8 improvement
    nghi-ly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant