-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable
retry
support for Microbatch models (#10751)
* Add `PartialSuccess` status type and use it for microbatch models with mixed results * Handle `PartialSuccess` in `interpret_run_result` * Add `BatchResults` object to `BaseResult` and begin tracking during microbatch runs * Ensure batch_results being propagated to `run_results` artifact * Move `batch_results` from `BaseResult` class to `RunResult` class * Move `BatchResults` and `BatchType` to separate arifacts file to avoid circular imports In our next commit we're gonna modify `dbt/contracts/graph/nodes.py` to import the `BatchType` as part of our work to implement dbt retry for microbatch model nodes. Unfortunately, the import in `nodes.py` creates a circular dependency because `dbt/artifacts/schemas/results.py` imports from `nodes.py` and `dbt/artifacts/schemas/run/v5/run.py` imports from that `results.py`. Thus the new import creates a circular import. Now this _shouldn't_ be necessary as nothing in artifacts should import from the rest of dbt-core. However, we do. We should fix this, but this is also out of scope for this segement of work. * Add `PartialSuccess` as a retry-able status, and use batches to retry microbatch models * Fix BatchType type so that the first datetime is no longer Optional * Ensure `PartialSuccess` causes skipping of downstream nodes * Alter `PartialSuccess` status to be considered an error in `interpret_run_result` * Update schemas and test artifacts to include new batch_results run results key * Add functional test to check that 'dbt retry' retries 'PartialSuccess' models * Update partition failure test to assert downstream models are skipped * Improve `success`/`error`/`partial success` messaging for microbatch models * Include `PartialSuccess` in status that `--fail-fast` counts as a failure * Update `LogModelResult` to handle partial successes * Update `EndOfRunSummary` to handle partial successes * Cleanup TODO comment * Raise a DbtInternalError if we get a batch run result without `batch_results` * When running a microbatch model with supplied batches, force non full-refresh behavior This is necessary because of retry. Say on the initial run the microbatch model succeeds on 97% of it's batches. Then on retry it does the last 3%. If the retry of the microbatch model executes in full refresh mode it _might_ blow away the 97% of work that has been done. This edge case seems to be adapter specific. * Only pass batches to retry for microbatch model when there was a PartialSuccess In the previous commit we made it so that retries of microbatch models wouldn't run in full refresh mode when the microbatch model to retry has batches already specified from the prior run. This is only problematic when the run being retried was a full refresh AND all the batches for a given microbatch model failed. In that case WE DO want to do a full refresh for the given microbatch model. To better outline the problem, consider the following: * a microbatch model had a begin of `2020-01-01` and has been running this way for awhile * the begin config has changed to `2024-01-01` and dbt run --full-refresh gets run * every batch for an microbatch model fails * on dbt retry the the relation is said to exist, and the now out of range data (2020-01-01 through 2023-12-31) is never purged To avoid this, all we have to do is ONLY pass the batch information for partially successful microbatch models. Note: microbatch models only have a partially successful status IFF they have both successful and failed batches. * Fix test_manifest unit tests to know about model 'batches' key * Add some console output assertions to microbatch functional tests * add batch_results: None to expected_run_results * Add changie doc for microbatch retry functionality * maintain protoc version 5.26.1 * Cleanup extraneous comment in LogModelResult --------- Co-authored-by: Michelle Ark <[email protected]>
- Loading branch information
1 parent
ac66f91
commit 1fd4d2e
Showing
29 changed files
with
479 additions
and
102 deletions.
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: Features | ||
body: Enable `retry` support for microbatch models | ||
time: 2024-09-25T16:50:02.105069-05:00 | ||
custom: | ||
Author: QMalcolm MichelleArk | ||
Issue: "10624" |
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,21 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
from typing import List, Tuple | ||
|
||
from dbt_common.dataclass_schema import dbtClassMixin | ||
|
||
BatchType = Tuple[datetime, datetime] | ||
|
||
|
||
@dataclass | ||
class BatchResults(dbtClassMixin): | ||
successful: List[BatchType] = field(default_factory=list) | ||
failed: List[BatchType] = field(default_factory=list) | ||
|
||
def __add__(self, other: BatchResults) -> BatchResults: | ||
return BatchResults( | ||
successful=self.successful + other.successful, | ||
failed=self.failed + other.failed, | ||
) |
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Oops, something went wrong.