-
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
Write microbatch compiled + run code to separate target files #10743
Changes from 7 commits
199ebf4
6c3aecc
9b92a1b
18c814b
750ccc1
cdb0bcb
efe3a1d
6da854a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Write microbatch compiled/run targets to separate files, one per batch | ||
time: 2024-09-20T17:24:19.219556+01:00 | ||
custom: | ||
Author: michelleark | ||
Issue: "10714" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
from dbt.tests.util import ( | ||
patch_microbatch_end_time, | ||
read_file, | ||
relation_from_name, | ||
run_dbt, | ||
run_dbt_and_capture, | ||
|
@@ -442,3 +443,78 @@ def test_run_with_event_time(self, project): | |
with patch_microbatch_end_time("2020-01-03 13:57:00"): | ||
run_dbt(["run", "--event-time-start", "2020-01-01"]) | ||
self.assert_row_count(project, "microbatch_model", 2) | ||
|
||
|
||
class TestMicrobatchCompiledRunPaths(BaseMicrobatchTest): | ||
@mock.patch.dict(os.environ, {"DBT_EXPERIMENTAL_MICROBATCH": "True"}) | ||
def test_run_with_event_time(self, project): | ||
# run all partitions from start - 2 expected rows in output, one failed | ||
with patch_microbatch_end_time("2020-01-03 13:57:00"): | ||
run_dbt(["run", "--event-time-start", "2020-01-01"]) | ||
|
||
# Compiled paths - compiled model without filter only | ||
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. After discussion with @graciegoheen, we decided it could still be useful to see the non-batched (no filters applied) model file, and at the top-level is where users would expect it. I've added a test to formalize this expected behaviour, but it's something that would be easy to change if we get beta feedback! |
||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"compiled", | ||
"test", | ||
"models", | ||
"microbatch_model.sql", | ||
) | ||
|
||
# Compiled paths - batch compilations | ||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"compiled", | ||
"test", | ||
"models", | ||
"microbatch_model", | ||
"microbatch_model_2020-01-01.sql", | ||
) | ||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"compiled", | ||
"test", | ||
"models", | ||
"microbatch_model", | ||
"microbatch_model_2020-01-02.sql", | ||
) | ||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"compiled", | ||
"test", | ||
"models", | ||
"microbatch_model", | ||
"microbatch_model_2020-01-03.sql", | ||
) | ||
|
||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"run", | ||
"test", | ||
"models", | ||
"microbatch_model", | ||
"microbatch_model_2020-01-01.sql", | ||
) | ||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"run", | ||
"test", | ||
"models", | ||
"microbatch_model", | ||
"microbatch_model_2020-01-02.sql", | ||
) | ||
assert read_file( | ||
project.project_root, | ||
"target", | ||
"run", | ||
"test", | ||
"models", | ||
"microbatch_model", | ||
"microbatch_model_2020-01-03.sql", | ||
) |
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.
nit
Feels somewhat weird that this is on the
ParsedNode
class instead of the MicrobatchBuilder class. Just feels out of place.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.
totally agree! I think at first I didn't do this because it's necessary in providers.py which didn't Added it as a static method. Good call 👍