-
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.
Fixes dbt retry does not respect --threads (#10591)
- Loading branch information
1 parent
407f6ca
commit 3464be7
Showing
4 changed files
with
74 additions
and
1 deletion.
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: dbt retry does not respect --threads | ||
time: 2024-08-22T12:21:32.358066+05:30 | ||
custom: | ||
Author: donjin-master | ||
Issue: "10584" |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
|
||
from dbt.contracts.results import RunStatus, TestStatus | ||
from dbt.tests.util import run_dbt, write_file | ||
from tests.functional.retry.fixtures import models__thread_model, schema_test_thread_yml | ||
|
||
|
||
class TestCustomThreadRetry: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"thread_model.sql": models__thread_model, | ||
"schema.yml": schema_test_thread_yml, | ||
} | ||
|
||
def test_thread_target(self, project): | ||
# Passing Threads to check | ||
results = run_dbt( | ||
["build", "--select", "thread_model", "--threads", "3"], expect_pass=False | ||
) | ||
expected_statuses = { | ||
"thread_model": RunStatus.Error, | ||
"not_null_thread_model_id": TestStatus.Skipped, | ||
} | ||
assert {n.node.name: n.status for n in results.results} == expected_statuses | ||
|
||
# Retry Running the Dbt with simple Retry | ||
results = run_dbt(["retry", "--threads", "2"], expect_pass=False) | ||
expected_statuses = { | ||
"thread_model": RunStatus.Error, | ||
"not_null_thread_model_id": TestStatus.Skipped, | ||
} | ||
assert {n.node.name: n.status for n in results.results} == expected_statuses | ||
assert results.args["threads"] == 2 | ||
|
||
# running with retry withour threads | ||
results = run_dbt(["retry"], expect_pass=False) | ||
expected_statuses = { | ||
"thread_model": RunStatus.Error, | ||
"not_null_thread_model_id": TestStatus.Skipped, | ||
} | ||
assert {n.node.name: n.status for n in results.results} == expected_statuses | ||
assert results.args["threads"] == 2 | ||
|
||
# Retry with fixing the model and running with --threads 1 | ||
fixed_sql = "select 1 as id" | ||
write_file(fixed_sql, "models", "thread_model.sql") | ||
|
||
results = run_dbt(["retry", "--threads", "1"]) | ||
expected_statuses = { | ||
"thread_model": RunStatus.Success, | ||
"not_null_thread_model_id": TestStatus.Pass, | ||
} | ||
|
||
assert {n.node.name: n.status for n in results.results} == expected_statuses | ||
assert results.args["threads"] == 1 |