Repository navigation
Fixes #32064: [MSSQL] Keep stored-procedure lineage when the engine returns no procedure body - #33369
Conversation
…eturns no procedure body sys.dm_exec_sql_text() returns a NULL text column for encrypted and CLR modules, and the MSSQL plan-cache statement selects it as PROCEDURE_TEXT, so those rows failed validation and the lineage run finished with failures. The rows were usable: the body is only a fallback for deriving the procedure name, and they already carried the name and the query text that lineage is parsed from. procedure_name and procedure_text are now str | None, since either one alone identifies the procedure, and the name fallback only parses a body when there is one. Failures now name the procedure they came from.
There was a problem hiding this comment.
🟡 Changes recommended
A critical issue remains because row conversion must stay inside the per-row error handler to prevent lineage runs from aborting.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes MSSQL stored-procedure lineage failures when procedure bodies are unavailable.
Changes:
- Allows nullable procedure names and bodies.
- Preserves fallback name parsing and improves failure diagnostics.
- Adds regression tests for missing procedure metadata.
File summaries
| File | Description |
|---|---|
ingestion/tests/unit/lineage/test_stored_procedure_lineage.py |
Adds regression coverage for unavailable procedure bodies and metadata. |
ingestion/src/metadata/ingestion/source/database/stored_procedures_mixin.py |
Handles nullable procedure metadata and reports procedure-specific errors. |
ingestion/src/metadata/ingestion/source/database/lineage_processors.py |
Makes procedure name and body fields optional. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Reading the row outside the try narrowed the protection the per-row handler exists for: the producer consumes this as a generator, so an exception escaping here drops every remaining row while the run still reports success. row_data is now bound before the try and assigned inside it, so the diagnostic still names the procedure.
✅ Playwright Results — workflow succeededValidated commit ✅ 109 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 47m 33s ⏱️ Max setup 4m 23s · max shard execution 12m 52s · max shard-job elapsed before upload 17m 46s · reporting 3s 🌐 238.77 requests/attempt · 1.77 app boots/UI scenario · 0.00% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review ✅ ApprovedFixes MSSQL stored-procedure lineage extraction when the engine returns no procedure body by making OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
| ) | ||
| row_data = row._asdict() | ||
| query_by_procedure = QueryByProcedure.model_validate(row_data) | ||
| if not query_by_procedure.procedure_name and query_by_procedure.procedure_text: |
There was a problem hiding this comment.
nit: when neither is there, the row just quietly disappears further down at the continue in the producer. probably fine, but a debug log there wouldn't hurt.
There was a problem hiding this comment.
fair point, it does vanish silently there. leaving it out of this one since it's in the queue, will add the debug log in a follow-up



Describe your changes:
Fixes #32064
sys.dm_exec_sql_text()returns a NULLtextcolumn for encrypted and CLR modules, and the MSSQL plan-cache statement selects it asPROCEDURE_TEXT. SinceQueryByProcedure.procedure_textwas required, those rows failed validation and the lineage run finished with failures.The rows were usable. The body is only a fallback for deriving the procedure name, and they already carried both the name and the query text that lineage is parsed from. So
procedure_nameandprocedure_textare nowstr | None, because either one alone identifies the procedure, and the name fallback only parses a body when there is one.procedure_namewas alreadystr = Field(None, ...), which tolerated an absent key but not an explicit NULL from the database. Making the annotation honest also let apyright: ignorego.Failures now name the procedure they came from:
Error trying to get procedure name for [usp_broken] due to [...].query_textandquery_typestay required, since a row with no query text carries no lineage.Type of change:
High-level design:
N/A, small change.
Tests:
Use cases covered
Unit tests
ingestion/tests/unit/lineage/test_stored_procedure_lineage.py, newTestProcedureBodyUnavailable(5 tests, 4 red before this change).ingestion/tests/unit/lineage/plus MSSQL topology tests: 507 passed, 2 skipped.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
On a SQL Server 2019 container with two stored procedures differing only in
WITH ENCRYPTION, the plain one as a control group.sys.dm_exec_sql_text().textandOBJECT_DEFINITION()are both NULL for the encrypted procedure and non-NULL for the plain one.MSSQL_GET_STORED_PROCEDURE_QUERIESverbatim through the realyield_stored_procedure_queries()and reproduced the reported error from a real connector row: 0 yielded, 1 failure.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.