Add DbtCloudListJobRunsOperator to DBT Cloud Provider#66150
Open
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
Open
Add DbtCloudListJobRunsOperator to DBT Cloud Provider#66150SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
Conversation
…ordering, and job_definition_id, and optionally returning only the most recent run via latest_only. Unit tests have been included.
fa3ffa8 to
f5ae4b1
Compare
Contributor
Author
|
Requesting review for this |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This change introduces a new operator,
DbtCloudListJobRunsOperator, to list job runs in dbt Cloud.The operator supports filtering by
job_idand status, ordering of results, and optional inclusion of related fields. It also provides alatest_onlymode to return the most recent job run, defaulting to descendingcreated_atordering when no explicitorder_byis provided.Rationale
Users often need to inspect or act upon dbt Cloud job runs within DAGs, such as retrieving the most recent successful run or filtering runs by status. While dbt Cloud provides APIs for listing job runs, there is currently no dedicated Airflow operator to expose this functionality in a structured and reusable way.
This operator provides a simple and flexible interface for these common workflows, aligning with existing patterns in the dbt Cloud provider and enabling use cases such as conditional branching based on job run state or auditing recent executions.
Tests
Added unit tests verifying that:
account_id,job_id,order_by) are correctly propagated to the hook.job_idis not provided, ensuring default parameters are passed to the hook.status_filterworks for both single and multiple status values, including cases where no runs match.None.latest_onlyreturns the most recent run when results are present andNonewhen no runs match after filtering.-created_atwhenlatest_only=Trueand no explicitorder_byis provided, while respecting user-defined overrides.Example DAGs
The example DAG
example_dbt_cloudhas been updated to include a task usingDbtCloudListJobRunsOperator, demonstrating how to list job runs for a given account and job.Documentation
A docstring for
DbtCloudListJobRunsOperatorhas been added to document parameters, filtering behavior, andlatest_onlysemantics.Backwards Compatibility
This is a new operator and does not modify existing functionality. No breaking changes are introduced.