Skip to content

Add DbtCloudListJobRunsOperator to DBT Cloud Provider#66150

Open
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
SameerMesiah97:DBTCloudListJobRunsOperator
Open

Add DbtCloudListJobRunsOperator to DBT Cloud Provider#66150
SameerMesiah97 wants to merge 1 commit intoapache:mainfrom
SameerMesiah97:DBTCloudListJobRunsOperator

Conversation

@SameerMesiah97
Copy link
Copy Markdown
Contributor

Description

This change introduces a new operator, DbtCloudListJobRunsOperator, to list job runs in dbt Cloud.

The operator supports filtering by job_id and status, ordering of results, and optional inclusion of related fields. It also provides a latest_only mode to return the most recent job run, defaulting to descending created_at ordering when no explicit order_by is 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:

  • Job runs are correctly retrieved and flattened from API responses, and arguments (account_id, job_id, order_by) are correctly propagated to the hook.
  • Job runs are retrieved correctly when job_id is not provided, ensuring default parameters are passed to the hook.
  • Filtering by status_filter works for both single and multiple status values, including cases where no runs match.
  • Status filtering correctly handles API responses where status values are returned as strings, are missing, or are None.
  • latest_only returns the most recent run when results are present and None when no runs match after filtering.
  • Ordering behavior defaults to -created_at when latest_only=True and no explicit order_by is provided, while respecting user-defined overrides.
  • Multi-page responses are correctly aggregated into a single result set.

Example DAGs

The example DAG example_dbt_cloud has been updated to include a task using DbtCloudListJobRunsOperator, demonstrating how to list job runs for a given account and job.

Documentation

A docstring for DbtCloudListJobRunsOperator has been added to document parameters, filtering behavior, and latest_only semantics.

Backwards Compatibility

This is a new operator and does not modify existing functionality. No breaking changes are introduced.

…ordering, and job_definition_id, and optionally returning only the most recent run via latest_only. Unit tests have been included.
@SameerMesiah97 SameerMesiah97 force-pushed the DBTCloudListJobRunsOperator branch from fa3ffa8 to f5ae4b1 Compare April 30, 2026 13:51
@SameerMesiah97 SameerMesiah97 marked this pull request as ready for review April 30, 2026 14:36
@SameerMesiah97
Copy link
Copy Markdown
Contributor Author

Requesting review for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant