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

add callout to use modules.datetime and modules.pytz for begin config #6921

Merged
merged 12 commits into from
Feb 18, 2025
22 changes: 22 additions & 0 deletions website/docs/reference/resource-configs/begin.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ Set the `begin` config to the timestamp value at which your [microbatch incremen

The following examples set `2024-01-01 00:00:00` as the `begin` config for the `user_sessions` model.

:::tip Did you know?

If you'd like to configure `begin` to use relative dates, you can use [`modules.datetime`](/reference/dbt-jinja-functions/modules#datetime) and [`modules.pytz`](/reference/dbt-jinja-functions/modules#pytz) to dynamically specify relative timestamps, such as yesterday's date or the start of the current week.

For example, to set `begin` to yesterday's date...

```sql
-- confirming with Grace/core team
{{
config(
materialized = 'incremental',
incremental_strategy='microbatch',
unique_key = 'run_id',
begin=(modules.datetime.datetime.utcnow() - modules.datetime.timedelta(days=1)).isoformat(),
event_time='created_at',
batch_size='day',
snowflake_warehouse = set_warehouse_config('large')
)
}}
```
:::

Example in the `dbt_project.yml` file:

<File name='dbt_project.yml'>
Expand Down
Loading