Repository navigation
[2.0] fix(ingestion): stop MSSQL GetTables/GetViews sorting the whole catalog (#32014) - #35906
Conversation
…og (#32014) GetTables/GetViews used inspector.get_table_names()/get_view_names(), which query INFORMATION_SCHEMA with an ORDER BY and no row cap. On a schema with hundreds of thousands of tables, SQL Server has to sort every row before returning one, which blows past the per-step test-connection timeout and aborts real ingestion before it starts. Replace them with a TOP 1, no-ORDER-BY existence probe against sys.tables/sys.views, filtered to is_ms_shipped = 0 so a probe against a system database (master, msdb) still reports on real user objects instead of SQL Server's own tables/views. Fixes #24101 (cherry picked from commit f8c5d97)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
Code Review ✅ Approved🟡 Medium risk · MSSQL connection checks now probe one user table or view instead of enumerating catalogs, which could miss object-specific visibility problems. Replaces the MSSQL test-connection GetTables/GetViews schema-listing calls with a TOP 1, no-ORDER BY probe against sys.tables/sys.views filtered to is_ms_shipped = 0, so the step no longer sorts the whole catalog and exceed the 60s timeout. Adds tests for found, empty, and caveat paths. No issues found. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Backport of #32014 (f8c5d97) to
2.0. Fixes #24101 on 2.0.On 2.0, the MSSQL test-connection GetTables/GetViews steps still reflect via
inspector.get_table_names()/get_view_names(), which queryINFORMATION_SCHEMA.TABLESwith anORDER BYand no row cap. On a large schema SQL Server sorts every row before returning one, so the step exceeds the 60s per-step timeout. The SIGALRM timeout then fires inside pyodbc (<class 'pyodbc.Error'> returned a result with an exception set) and leaves the connection unrecoverable (IMC06). This has been seen on 2.0 customer deployments.The fix replaces both with a
TOP 1, no-ORDER BYprobe againstsys.tables/sys.viewsfiltered tois_ms_shipped = 0.Conflict resolution
connection.py: imports only. 2.0 already hasdeepcopy/Anyfor the query-timeout code;dataclasses.replacefrom Fixes 24101: stop MSSQL GetTables/GetViews from timing out on large catalogs #32014 is added next to them.test_connection.py: both sides appended independent test blocks (query-timeout tests on 2.0, probe tests from Fixes 24101: stop MSSQL GetTables/GetViews from timing out on large catalogs #32014). Both are kept.Tests
pytest tests/unit/source/database/mssql/→ 54 passed (2.0 models regenerated)ruff format --check/ruff check(0.15) on the changed files → clean🤖 Generated with Claude Code
Summary by Gitar
GetTablesnow adds a caveat when no tables are visible, whileGetViewsstays silent when emptySYSTEM_SCHEMASfilter fromMssqlChecks, since the new probe replaces the schema-based listingtest_connection.pycases covering the probe's found, empty, and caveat paths using a mockedrun_sqlMSSQL_TEST_GET_TABLESandMSSQL_TEST_GET_VIEWSusingTOP 1withoutORDER BYto avoid sorting the full catalogThis will update automatically on new commits.


Confidence Score: 5/5
The PR appears safe to merge.Summary
Replaces MSSQL table and view reflection with small existence checks.
No actionable issues found. Tests were not run during this review.
Reviews (1) · Last reviewed commit: "fix(ingestion): stop MSSQL GetTables/Get..." · Reviewed by Greptile