Skip to content

[2.0] Fixes #22769: Ingest dbt Cloud artifacts from multiple jobs (#36596) - #37987

Merged
ulixius9 merged 2 commits into
2.0from
backport/2.0-dbt-cloud-multi-job
Nov 20, 2026
Merged

ulixius9 merged 2 commits into
2.0from
backport/2.0-dbt-cloud-multi-job

Conversation

@ulixius9

@ulixius9 ulixius9 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Backport of #36596 (Fixes #22769) to 2.0: cherry-picked with -x from ab11430bc4d.

Why

On 2.0 the dbt Cloud source reads one run's manifest.json, and dbt only sets compiled_code on the nodes that run compiled. A deployment whose ingested job runs a partial selection gets rawSql but no compiled sql on nearly every model. With #36596 the user can list several job IDs (or set dbtCloudIngestAllJobs), and the artifacts are merged per environment so compiled SQL from a full job isn't lost.

Conflicts resolved

  • dbt_config.py imports: 2.0 still uses typing.Dict/List/Optional/Tuple (# noqa: UP035), so Any was added to that import instead of main's collections.abc form; the function-level imports keep 2.0's # noqa: PLC0415.
  • ingestion/.ruff-g004-baseline.json and the three ui/src/jsons/ingestionSchemas/*.json copies don't exist on 2.0, so those hunks were dropped.

The schema change is additive (dbtCloudIngestAllJobs, default false); dbtCloudJobId stays a string. No migration needed.

Tests

On this branch with regenerated Python models:

  • pytest tests/unit/test_dbt_config_errors.py tests/unit/test_dbt.py: 361 passed
  • ruff check / ruff format --check on the changed Python files: clean

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the existing non-blocking gap in request metrics.

Findings

  1. P2 Artifact downloads lose request metrics ▶

Summary

Adds dbt Cloud ingestion from several jobs, merging their artifacts within each environment while keeping the existing single-run default.

  • dbt Cloud ingestion combines selected jobs into one artifact set per environment.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[dbt Cloud configuration] --> B{Several jobs selected?}
    B -->|No| C[Read one latest completed run]
    B -->|Yes| D[Find latest completed run for each job]
    D --> E[Group runs by environment]
    E --> F[Download and merge one environment]
    F --> G{Artifacts readable and schemas match?}
    G -->|Yes| H[Yield merged artifacts]
    G -->|No| I[Record failed environment]
    H --> J[Continue with next environment]
    I --> J
    J --> K[Report any failed environments]
Loading

Reviews (2) · Last reviewed commit: "Merge branch '2.0' into backport/2.0-dbt..." · Reviewed by Greptile

* dbt Cloud: ingest from multiple jobs or all jobs

Accept comma-separated dbt Cloud job IDs and add an opt-in
dbtCloudIngestAllJobs flag that reads the latest completed run of every
non-CI job. With no job IDs and the flag off, the single most recent run
is read, as before.

* dbt Cloud: merge job artifacts per environment

Each job's manifest lists every model but only carries compiled SQL for
the models that job built, so processing jobs one by one let a partial
job blank out a full one. Merge the artifacts of jobs sharing an
environment, preferring compiled nodes; skip jobs whose runs call fails
for reasons other than auth, and keep the default path's messages.

* dbt Cloud: skip only jobs without a run; merge one environment at a time

Skipping every non-auth failure let a 429 or dbt Cloud's nested-status
401 drop a job silently and blank the models only it compiled. Skip only
jobs with no completed run, retry 429, and download, merge and yield one
environment at a time. Add the decision record.

* dbt Cloud: fail a merge on any failed artifact; newest run wins ties

In merge mode, fetch catalog and run_results with get_raw so only a 404
reads as absent; get also returns None after exhausting retries. Merge
each environment's runs newest first. Cover the 429 retry with a test
that drives the real REST client.

* dbt Cloud: refuse to merge manifests of different dbt versions

A job can override its environment's dbt version, and the manifest
parser validates every node against the merged manifest's one schema
version. Fail naming both jobs instead. Name the job and run when a
merge finds no manifest, and warn when the default path gets no catalog.

* dbt Cloud: newest manifest decides the merged nodes

Unioning nodes let a paused job's old run bring back models removed
since, and replace a node's current config with an old one. Keep the
newest run's nodes and only fill in compiled fields from older runs.
Read a duplicated job ID once and warn once on a missing catalog.

* dbt Cloud: a broken job skips only its environment

Tested on a real account: an abandoned ad-hoc job whose last run failed
at dbt seed has no manifest, and failing the whole scan on it would
leave every later environment un-ingested. Leave that environment out,
ingest the others, then fail the run naming the skipped environments.

* docs: rewrap dbt Cloud multi-job decision record

* Update generated TypeScript types and dereferenced schemas

* dbt Cloud: an unreadable artifact skips only its environment

A transport failure or a non-JSON body on a merged run's artifact escaped
the per-environment guard and ended ingestion of every later environment.
Both are now raised as DBTConfigException where the artifact is fetched.

The decision record now says only listing jobs or runs fails at once; an
artifact denied to the token skips its environment like any other failure.

Also fixes CI: lazy %-style logging for the new log lines (G004, baseline
pruned) and a dict[str, Any] annotation for the jobs query params.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit ab11430)
@ulixius9
ulixius9 requested review from a team as code owners November 17, 2026 13:40
@ulixius9
ulixius9 requested review from Khairajani and ShaileshParmar11 and removed request for a team November 17, 2026 13:40
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

from metadata.ingestion.ometa.client import RestTransportError # noqa: PLC0415

try:
response = client.get_raw(path, data=data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Artifact downloads lose request metrics

Multi-job downloads now use get_raw, which bypasses the source_api_calls tracking in TrackedREST.get. Catalog, manifest, and test-result downloads disappear from request counts and durations, making slow or rate-limited scans harder to diagnose. Keep the raw response checks, but add tracking for get_raw.

@gitar-bot

gitar-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Merging dbt Cloud artifacts across jobs changes ingested model SQL and catalog data; incorrect environment grouping could produce inaccurate metadata.

Backports multi-job dbt Cloud artifact ingestion to 2.0, letting users list several job IDs or enable dbtCloudIngestAllJobs so compiled SQL from full runs is merged per environment. Conflict resolutions preserve 2.0 import styles, and the schema change is additive. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@ulixius9
ulixius9 merged commit 4143e07 into 2.0 Nov 20, 2026
71 of 85 checks passed
@ulixius9
ulixius9 deleted the backport/2.0-dbt-cloud-multi-job branch November 20, 2026 17:45
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.

2 participants