SameerMesiah97 opened a new pull request, #66150: URL: https://github.com/apache/airflow/pull/66150
**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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
