-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Track batch execution time for microbatch models #10828
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5153c6b
Begin testing that microbatch execution times are being tracked and set
QMalcolm d68c6f5
Begin tracking the execution time of batches for microbatch models
QMalcolm 1e2e23a
Add changie doc
QMalcolm b9f7332
Additional assertions in microbatch testing
QMalcolm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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: Fixes | ||
body: Begin tracking execution time of microbatch model batches | ||
time: 2024-10-04T16:39:08.464064-05:00 | ||
custom: | ||
Author: QMalcolm | ||
Issue: "10825" |
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import pytest | ||
|
||
from dbt.events.types import LogModelResult | ||
from dbt.tests.util import ( | ||
get_artifact, | ||
patch_microbatch_end_time, | ||
|
@@ -12,6 +13,7 @@ | |
run_dbt_and_capture, | ||
write_file, | ||
) | ||
from tests.utils import EventCatcher | ||
|
||
input_model_sql = """ | ||
{{ config(materialized='table', event_time='event_time') }} | ||
|
@@ -186,10 +188,22 @@ class TestMicrobatchCLI(BaseMicrobatchTest): | |
@mock.patch.dict(os.environ, {"DBT_EXPERIMENTAL_MICROBATCH": "True"}) | ||
def test_run_with_event_time(self, project): | ||
# run without --event-time-start or --event-time-end - 3 expected rows in output | ||
catcher = EventCatcher(event_to_catch=LogModelResult) | ||
|
||
with patch_microbatch_end_time("2020-01-03 13:57:00"): | ||
run_dbt(["run"]) | ||
run_dbt(["run"], callbacks=[catcher.catch]) | ||
self.assert_row_count(project, "microbatch_model", 3) | ||
|
||
assert len(catcher.caught_events) == 5 | ||
batch_creation_events = 0 | ||
for caught_event in catcher.caught_events: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe assert the number of events here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can do! |
||
if "batch 2020" in caught_event.data.description: | ||
batch_creation_events += 1 | ||
assert caught_event.data.execution_time > 0 | ||
# 3 batches should have been run, so there should be 3 batch | ||
# creation events | ||
assert batch_creation_events == 3 | ||
|
||
# build model >= 2020-01-02 | ||
with patch_microbatch_end_time("2020-01-03 13:57:00"): | ||
run_dbt(["run", "--event-time-start", "2020-01-02", "--full-refresh"]) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this pattern is used in many places, let's refactor them all at once?
For now, this should be fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. However, we wouldn't be able to use that in this util. I think that fixture would likely make most sense
tests/
notcore/dbt/tests/
. This utility function (run_dbt
) wouldn't have access to it. That doesn't mean we shouldn't do that work, but it's out of scope for this PR and should be its own segment of work.