Repository navigation
Conversation
Contributor
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
ulixius9
approved these changes
Oct 15, 2026
ulixius9
deleted the
detail/bug-fix/fixes-35101-keep-clr-stored-procedures-in-the-mssq-415f9e
branch
October 15, 2026 23:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Detail bug report: View on Detail
Describe your changes:
Fixes #35101
I worked on MSSQL ingestion silently dropping CLR (assembly) stored procedures from the catalogue.
MSSQL_GET_STORED_PROCEDURESsourced the proceduredefinitionvia anINNER JOIN sys.sql_modules— added in PR #16002 to fix the 4000-character truncation ofINFORMATION_SCHEMA.ROUTINES.ROUTINE_DEFINITION. Butsys.sql_moduleshas no row for CLR procedures (sys.objects.type = 'PC'; their definition lives insys.assembly_modules), so the INNER JOIN dropped every CLR procedure before it reached Python and left the shippedEXTERNAL -> Language.Externallanguage map as dead code. The original (pre-#16002) query returned CLR procedures (withROUTINE_BODY='EXTERNAL'andROUTINE_DEFINITION=NULL), so this is a regression.Type of change:
High-level design:
Changed
JOIN sys.sql_modulestoLEFT JOIN sys.sql_modulesinMSSQL_GET_STORED_PROCEDURES(ingestion/src/metadata/ingestion/source/database/mssql/queries.py). CLR procedures now survive the join withdefinition = NULL.yield_stored_procedurealready handlesdefinition=None— the encrypted-procedure placeholder is only substituted for names in the per-(database, schema) encrypted cache (queried viaOBJECTPROPERTY(object_id, 'IsEncrypted') = 1, which is only true for T-SQLWITH ENCRYPTION), so a CLR procedure is emitted withlanguage=Language.Externalandcode=None. Nomodels.pychange was needed; the pre-existingEXTERNALarm ofSTORED_PROC_LANGUAGE_MAPbecomes live again. T-SQL procedures are unaffected — each has exactly onesys.sql_modulesrow, so the LEFT JOIN returns the same single row the INNER JOIN did (no row duplication).Tests:
Use cases covered:
language='EXTERNAL',definition=None) survivesMSSQL_GET_STORED_PROCEDURESand is parsed/yielded byget_stored_procedures.Language.Externalwithcode=None— the previously-deadEXTERNALarm ofSTORED_PROC_LANGUAGE_MAP.WITH ENCRYPTION).sys.sql_modulesjoin stays aLEFT JOIN(regression guard against reintroducing the INNER JOIN).Unit tests:
Added
TestMssqlClrStoredProceduresiningestion/tests/unit/topology/database/test_mssql.py(4 tests):JOIN sys.sql_modulesis aLEFT JOIN;get_stored_proceduresyields a mocked CLR row withlanguage=='EXTERNAL'anddefinition is None;yield_stored_procedureemitsstoredProcedureCode.language == Language.Externalandcode is None;code=Noneeven when the encrypted cache holds other proc names.The full
test_mssql.pysuite (68 tests including the 4 new) passes. ruff check + format are clean, and basedpyright reports no new errors from the change (the 3 pre-existing errors on the pristine tree are all in untouched files / missing optional deps).Ingestion integration tests:
Ran the existing MSSQL stored-procedure integration tests against a Testcontainers MSSQL 2022 container —
test_stored_procedures_fanout.py(cross-schema no-fanout) andtest_stored_procedures_apostrophe.py(apostrophe-name). Both pass, confirming the LEFT JOIN fix does not regress T-SQL procedures, cross-schema scoping, or the bound-parameter path.Manual testing performed:
End-to-end CLR verification against a Testcontainers MSSQL 2022 container — enabled CLR (
sp_configure 'clr enabled', 1), compiled a tiny[SqlProcedure].NET assembly (Monomcs), registered it viaCREATE ASSEMBLY FROM 0x…(trusting it throughsp_add_trusted_assemblyforclr strict security), and created a CLR stored procedure alongside a T-SQL control procedure. The fixed query returned the CLR proc withlanguage='EXTERNAL'anddefinition is None, while the T-SQL proc kept its full definition; re-running the pre-fixINNER JOINquery against the same fixture confirmed it omits the CLR proc. This scratch test was not committed (it needs a compiled .NET assembly and Mono tooling), but the unit tests above lock the fix.Backend integration tests / Playwright (UI) tests: N/A.
UI screen recording / screenshots:
N/A — no UI change.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Automatic Fixes PRs can be configured here.