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

fix wrong payload set when reuse_existing_run set to True in DbtCloudRunJobOperator #39271

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/providers/dbt/cloud/operators/dbt.py
Expand Up @@ -135,7 +135,7 @@ def execute(self, context: Context):
account_id=self.account_id,
payload={
"job_definition_id": self.job_id,
"status": DbtCloudJobRunStatus.NON_TERMINAL_STATUSES,
"status__in": DbtCloudJobRunStatus.NON_TERMINAL_STATUSES,
"order_by": "-created_at",
},
).json()["data"]
Expand Down
19 changes: 12 additions & 7 deletions tests/providers/dbt/cloud/operators/test_dbt.py
Expand Up @@ -312,9 +312,9 @@ def test_execute_no_wait_for_termination(self, mock_run_job, conn_id, account_id
ids=["default_account", "explicit_account"],
)
def test_execute_no_wait_for_termination_and_reuse_existing_run(
self, mock_run_job, mock_get_jobs_run, conn_id, account_id
self, mock_run_job, mock_get_job_runs, conn_id, account_id
):
mock_get_jobs_run.return_value.json.return_value = {
mock_get_job_runs.return_value.json.return_value = {
"data": [
{
"id": 10000,
Expand Down Expand Up @@ -354,12 +354,17 @@ def test_execute_no_wait_for_termination_and_reuse_existing_run(
assert operator.schema_override == self.config["schema_override"]
assert operator.additional_run_config == self.config["additional_run_config"]

with patch.object(DbtCloudHook, "get_job_run") as mock_get_job_run:
operator.execute(context=self.mock_context)

mock_run_job.assert_not_called()
operator.execute(context=self.mock_context)

mock_get_job_run.assert_not_called()
mock_run_job.assert_not_called()
mock_get_job_runs.assert_called_with(
account_id=account_id,
payload={
"job_definition_id": self.config["job_id"],
"status__in": DbtCloudJobRunStatus.NON_TERMINAL_STATUSES,
"order_by": "-created_at",
},
)

@patch.object(DbtCloudHook, "trigger_job_run")
@pytest.mark.parametrize(
Expand Down