Skip to content

fix(databricks): read dbt job results from test lines only and say when output is unread - #1169

Closed
fas89 wants to merge 2 commits into
mainfrom
fix/databricks-dbt-report-lines
Closed

fas89 wants to merge 2 commits into
mainfrom
fix/databricks-dbt-report-lines

Conversation

@fas89

@fas89 fas89 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

What and why

After fluid apply --mode amend-and-build runs a Databricks dbt job, forge reports each contract rule from the dbt task's output. Two things in that report were wrong:

  • Unread output was blamed on dbt. When reading the dbt task's output (runs/get-output) failed after a run that succeeded, or after the dbt task passed and a later task failed, the error was dropped and the rules were reported from empty logs as "dbt stopped before running them". The report now says the output could not be read, with the (scrubbed, bounded) error, and that the run page lists each rule, as the failed-task path already did. A build with no contract rules prints nothing new.
  • A model line could give a rule its status. The report read any N of M <STATUS> <word> line as a test result, so ERROR creating sql table model main.orders or SKIP relation main.downstream gave a status to a test named creating or main. A result now counts only when the test name is followed by dbt's padding (dots, or the bracketed status), as dbt prints a test line; model, seed, snapshot, skipped-relation and source freshness lines carry more words and are not read.

Borrow

  • dbt-core 1.10.latest core/dbt/events/types.py: the message formats of LogTestResult, LogModelResult, LogSeedResult, LogSnapshotResult, SkippingDetails, LogSkipBecauseError, LogFreshnessResult, LogHookEndLine and unit tests (model::v). Every non-test node line carries more words before the padding than a test line.
  • dbt-common format_fancy_output_line pads the message with dots to a fixed width and then prints [STATUS]; the padding shape is pinned by this repo's existing captured-output tests.
  • Repo: the failed-task path in build_runners/_databricks_job_run.py already reported unread output with databricks_enforce.scrub; the new lines reuse it.

Validation

  • Failing first: 11 new tests failed on the base (9 node-line shapes, the model-line rule, both unread-output paths); all pass now.
  • Touched suites (tests/build_runners/test_databricks*.py, tests/iac/test_iac_databricks_dbt*.py, tests/iac/test_iac_databricks_jobs*.py, tests/cli/test_apply_databricks*.py): 452 passed, 1 skipped.
  • Full suite: 55,157 passed, 5 failed. Four fail on main too (an AWS endpoint test, a dotenv dbt reload test, two DuckDB sandbox tests) and one passes when run alone (machine load). Rebased since onto current main with no change to the branch's patches; touched suites pass again (255 passed).
  • ripwire --quality-delta (the branch diff applied to a fresh copy of main, where a one-line change exits 0): 7 rows, all pairs of tests: the new tests share the arrange-and-assert shape of their neighbours in tests/build_runners/test_databricks_job_run.py. No source function grew or was copied.
  • CI lint battery (ruff, dead-code sweep, black 26.10.1, product guardrail, detect-secrets on touched files), bare scripts/mypy_strict.py, license-header and source-fence tests: green.

Reviews

  • Verifier: pass. Every genuine dbt test line shape still parses (PASS, FAIL n, WARN n, ERROR, SKIP test, names with no dot padding, ANSI colour, CRLF); every model, seed, snapshot, skip, freshness and hook line gives no result. One low note: a result line with nothing after the name no longer parses; dbt never prints that shape.
  • Defect scan (diff mode): no critical, high or medium finding. The new line goes through the same scrub and length cap as the failed-task line; _task_output always returns a mapping.

Known limits

  • Names with dots, hyphens or :: (singular tests, unit test versions) were never read correctly and are still not read; contract rule tests are named fluid_dq_<id>, so the rules are unaffected.

fas89 added 2 commits December 2, 2026 08:46
After a Databricks dbt job run that succeeded, or whose dbt task passed
before a later task failed, fluid apply dropped the error from reading
the dbt task's output and reported the contract rules from empty logs:
"dbt stopped before running them". It now says the output could not be
read, with the error, and that the run page lists each rule, as the
failed-task path already did.

Signed-off-by: Speculator55005 <50082482+fas89@users.noreply.github.com>
The per-rule report read any "N of M <STATUS> <word>" line as a test, so
"ERROR creating sql table model main.orders" or "SKIP relation
main.downstream" gave a status to a test named "creating" or "main". A
result now counts only when the name is followed by dbt's padding (dots
or the bracketed status), as dbt prints it for a test; a model, seed,
snapshot, skipped relation or source freshness line carries more words
and is not read.

Signed-off-by: Speculator55005 <50082482+fas89@users.noreply.github.com>
@github-actions github-actions Bot added tests Test coverage or test infrastructure changes needs-docs Pull request needs a linked docs update or justification labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

📄 Documentation Reminder

This PR appears to be missing a documentation reference. Our docs live in a separate repo.

Please update the PR description with one of:

  • Link a docs PR — check the "Docs PR linked" box and paste the URL
  • Mark as no docs needed — check "No docs needed" with a justification
  • Acknowledge docs TODO — check "Docs TODO" and create the docs PR before merge

See the Contributing Guide for details.

@fas89

fas89 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

This change now lives in #1188, together with the related dbt and plan changes.

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

Labels

needs-docs Pull request needs a linked docs update or justification tests Test coverage or test infrastructure changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant