event_time
Available in the dbt Cloud "Latest" release track and dbt Core v1.9 and higher.
- Models
- Seeds
- Snapshots
- Sources
models:
resource-path:
+event_time: my_time_field
models:
- name: model_name
config:
event_time: my_time_field
{{ config(
event_time='my_time_field'
) }}
seeds:
resource-path:
+event_time: my_time_field
seeds:
- name: seed_name
config:
event_time: my_time_field
snapshots:
resource-path:
+event_time: my_time_field
sources:
resource-path:
+event_time: my_time_field
sources:
- name: source_name
config:
event_time: my_time_field
Definition
Set the event_time
to the name of the field that represents the timestamp of the event -- "at what time did the row occur" -- as opposed to an event ingestion date. You can configure event_time
for a model, seed, or source in your dbt_project.yml
file, property YAML file, or config block.
Here are some examples of good and bad event_time
columns:
-
✅ Good:
account_created_at
— This represents the specific time when an account was created, making it a fixed event in time.session_began_at
— This captures the exact timestamp when a user session started, which won’t change and directly ties to the event.
-
❌ Bad:
_fivetran_synced
— This isn't the time that the event happened, it's the time that the event was ingested.last_updated_at
— This isn't a good use case as this will keep changing over time.
event_time
is required for Incremental microbatch and highly recommended for Advanced CI's compare changes in CI/CD workflows, where it ensures the same time-slice of data is correctly compared between your CI and production environments.
Examples
- Models
- Seeds
- Snapshots
- Sources
Here's an example in the dbt_project.yml
file:
models:
my_project:
user_sessions:
+event_time: session_start_time
Example in a properties YAML file:
models:
- name: user_sessions
config:
event_time: session_start_time
Example in sql model config block:
{{ config(
event_time='session_start_time'
) }}
This setup sets session_start_time
as the event_time
for the user_sessions
model.
Here's an example in the dbt_project.yml
file:
seeds:
my_project:
my_seed:
+event_time: record_timestamp
Example in a seed properties YAML:
seeds:
- name: my_seed
config:
event_time: record_timestamp
This setup sets record_timestamp
as the event_time
for my_seed
.
Here's an example in the dbt_project.yml
file:
snapshots:
my_project:
my_snapshot:
+event_time: record_timestamp
Example in a snapshot properties YAML:
snapshots:
- name: my_snapshot
config:
event_time: record_timestamp
This setup sets record_timestamp
as the event_time
for my_snapshot
.
Here's an example of source properties YAML file:
sources:
- name: source_name
tables:
- name: table_name
config:
event_time: event_timestamp
This setup sets event_timestamp
as the event_time
for the specified source table.