begin
Definition
Set the begin
config to the timestamp value at which your microbatch incremental model data should begin — at the point the data becomes relevant for the microbatch model. You can configure begin
for a model in your dbt_project.yml
file, property YAML file, or config block. The value for begin
must be a string representing an ISO-formatted date or date and time.
Examples
The following examples set 2024-01-01 00:00:00
as the begin
config for the user_sessions
model.
If you'd like to configure begin
to use relative dates, you can use modules.datetime
and 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...
-- confirming with Grace/core team
{{
config(
materialized = 'incremental',
incremental_strategy='microbatch',
unique_key = 'run_id',
begin=(modules.datetime.datetime.now() - modules.datetime.timedelta(1)).isoformat(),
event_time='created_at',
batch_size='day',
snowflake_warehouse = set_warehouse_config('large')
)
}}
Example in the dbt_project.yml
file:
models:
my_project:
user_sessions:
+begin: "2024-01-01 00:00:00"
Example in a properties YAML file:
models:
- name: user_sessions
config:
begin: "2024-01-01 00:00:00"
Example in sql model config block:
{{ config(
begin='2024-01-01 00:00:00'
) }}