-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
dbt-bigquery/.changes/unreleased/Features-20250207-090315.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Leverage static partitioning in dbt-bigquery materialization strategy | ||
time: 2025-02-07T09:03:15.963098Z | ||
custom: | ||
Author: borjav | ||
Issue: "538" |
27 changes: 27 additions & 0 deletions
27
dbt-bigquery/src/dbt/include/bigquery/macros/adapters/datetime.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% macro generate_dates_in_range(start_date_datetime, end_date_datetime, granularity) %} | ||
{#-- Generate a list of datetimes between two dates #} | ||
{% set total_offset_seconds = (end_date_datetime - start_date_datetime).total_seconds() %} | ||
{% set total_offset_hours = (total_offset_seconds/3600)|int %} | ||
{% set total_offset_days = (total_offset_hours/24)|int %} | ||
|
||
{% if granularity == "day" %} | ||
{% set total_offset = total_offset_days %} | ||
{% set fmt_out = '"%Y-%m-%d"' %} | ||
{% elif granularity == "hour" %} | ||
{% set total_offset = total_offset_hours %} | ||
{% set fmt_out = '"%Y-%m-%d %H:%M:%S"' %} | ||
{% endif %} | ||
|
||
{% set date_list = [] %} | ||
{% for i in range(0, total_offset ) -%} | ||
{% if granularity == "day" %} | ||
{% set delta = modules.datetime.timedelta(days = i) %} | ||
{% elif granularity == "hour" %} | ||
{% set delta = modules.datetime.timedelta(hours = i) %} | ||
{% endif %} | ||
{% set this_date = start_date_datetime + delta %} | ||
{% set _ = date_list.append(this_date.strftime(fmt_out)) %} | ||
{% endfor -%} | ||
{{ log("date_list: " ~ date_list,info=true) }} | ||
{{ return(date_list) }} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters