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

[Core] New jinja model.batch context #6585

Closed
QMalcolm opened this issue Dec 3, 2024 · 0 comments · Fixed by #6590
Closed

[Core] New jinja model.batch context #6585

QMalcolm opened this issue Dec 3, 2024 · 0 comments · Fixed by #6590
Assignees
Labels
content Improvements or additions to content dbt Core The changes proposed in this issue relate to dbt Core dbt-core v1.9

Comments

@QMalcolm
Copy link
Contributor

QMalcolm commented Dec 3, 2024

Link to the page(s) on docs.getdbt.com requiring updates

Tell us more about this update

We've added a new batch object to the already existing model dbt-jinja-functions. I'm not sure exactly how this should be documented, as it a new thing on an already existing "dbt-jinja-function" and not a new "dbt-jinja-function" itself (depending on how you think about it).

batch properties

The batch qualities available are:

  • id (i.e. model.batch.id)
    • This is the "unique" id for the batch within the context of the microbatch model
  • event_time_start (i.e. model.batch.event_time_start)
    • This is the start time of the batch's event time filter (inclusive)
  • event_time_end (i.e. model.batch.event_time_end)
    • This is the end time of the batch's event_time_filter (exclusive)

things to call out

  1. model.batch is only ever populated in the context of a microbatch model batch execution
    a. that is, outside of batch execution model.batch = None and the sub properties are unaccsible
  2. Given (1a) it is recommended to guard any accessing of the underlying properties

Example of (2)

{% if model.batch %}
  {{ log(model.batch.id) }}
{% endif %}

Reviewers/Stakeholders/SMEs

Related GitHub issues

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content dbt Core The changes proposed in this issue relate to dbt Core dbt-core v1.9
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants