Skip to content

fix: Skip mark_databases_as_deleted for single-database connectors#27333

Open
ulixius9 wants to merge 2 commits intomainfrom
fix/azuresql-mark-deleted-databases
Open

fix: Skip mark_databases_as_deleted for single-database connectors#27333
ulixius9 wants to merge 2 commits intomainfrom
fix/azuresql-mark-deleted-databases

Conversation

@ulixius9
Copy link
Copy Markdown
Member

@ulixius9 ulixius9 commented Apr 14, 2026

Summary

  • Fixed Azure SQL AZURE_SQL_GET_DATABASES query to use sys.databases instead of master.sys.databases — the master. prefix is not supported on Azure SQL Database (single database tier), causing mark_databases_as_deleted post-process to crash.
  • Added a guard in mark_databases_as_deleted that skips the entire post-process step when the source is a MultiDBSource with ingestAllDatabases=false. When only ingesting a single configured database, querying all databases to mark deletions is unnecessary and can fail on platforms like Azure SQL Database.
  • Added new Azure SQL topology unit tests and updated existing Postgres tests to cover the new guard behavior.

Test plan

  • All 23 existing Postgres topology tests pass
  • All 8 new Azure SQL topology tests pass
  • Verified mark_databases_as_deleted skips when get_configured_database() returns a value (single-db mode)
  • Verified mark_databases_as_deleted proceeds when get_configured_database() returns None (all-db mode)
  • Verified BigQuery/BigTable behavior unchanged (always returns None, so deletion always runs)

🤖 Generated with Claude Code

…d fix Azure SQL query

Azure SQL Database (single database tier) does not support cross-database
references like `master.sys.databases`, causing the metadata agent post-process
step to fail even when `ingestAllDatabases` is false.

Two fixes:
1. Changed `AZURE_SQL_GET_DATABASES` query to use `sys.databases` instead of
   `master.sys.databases` for Azure SQL Database compatibility.
2. Added a guard in `mark_databases_as_deleted` that skips the post-process
   step when the source is a `MultiDBSource` with a configured single database
   (`get_configured_database() is not None`). This prevents unnecessary queries
   when only one database is being ingested.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ulixius9 ulixius9 requested a review from a team as a code owner April 14, 2026 03:19
Copilot AI review requested due to automatic review settings April 14, 2026 03:19
@github-actions github-actions bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Apr 14, 2026
When `ingestAllDatabases` is false, the `mark_databases_as_deleted` post-process
step would still query all databases from the source to mark deletions. On
Azure SQL Database (single database tier), this fails because
`master.sys.databases` is not supported.

Added a guard in `mark_databases_as_deleted` that skips the post-process step
when the source is a `MultiDBSource` with a configured single database
(`get_configured_database() is not None`). When only ingesting one database,
querying all databases to mark deletions is unnecessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 14, 2026

Code Review ✅ Approved

Single-database connectors now skip the mark_databases_as_deleted operation, optimizing resource usage for connectors that manage only one database. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents database-deletion post-processing from running in “single database” ingestion mode for multi-database connectors (notably Azure SQL Database), and fixes the Azure SQL database listing query to be compatible with Azure SQL Database’s single-database tier.

Changes:

  • Update Azure SQL AZURE_SQL_GET_DATABASES to query sys.databases (no master. prefix).
  • Add a guard in mark_databases_as_deleted to skip deletion marking when a MultiDBSource is configured for single-db ingestion (get_configured_database() != None).
  • Add Azure SQL topology unit tests and extend Postgres topology tests to cover the new guard behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
ingestion/tests/unit/topology/database/test_postgres.py Updates existing deletion-marking tests to explicitly simulate “ingest all DBs” and adds coverage for the new single-db skip guard.
ingestion/tests/unit/topology/database/test_azuresql.py Adds topology unit tests validating Azure SQL’s configured-db behavior, deletion skip guard, and the updated databases query string.
ingestion/src/metadata/ingestion/source/database/database_service.py Implements the guard to skip mark_databases_as_deleted when running a MultiDBSource in single-db mode.
ingestion/src/metadata/ingestion/source/database/azuresql/queries.py Fixes Azure SQL database listing query to use sys.databases without master. prefix.

@github-actions
Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (29 flaky)

✅ 3596 passed · ❌ 0 failed · 🟡 29 flaky · ⏭️ 207 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 456 0 1 2
🟡 Shard 2 641 0 3 32
🟡 Shard 3 643 0 6 26
🟡 Shard 4 621 0 6 47
🟡 Shard 5 607 0 2 67
🟡 Shard 6 628 0 11 33
🟡 29 flaky test(s) (passed on retry)
  • Pages/UserCreationWithPersona.spec.ts › Create user with persona and verify on profile (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/ChangeSummaryBadge.spec.ts › AI badge should NOT appear for manually-edited descriptions (shard 2, 1 retry)
  • Features/DataQuality/TableLevelTests.spec.ts › Table Column Count To Be Between (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Complete Incident lifecycle with table owner (shard 3, 1 retry)
  • Features/Permissions/GlossaryPermissions.spec.ts › Team-based permissions work correctly (shard 3, 1 retry)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 1 retry)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 1 retry)
  • Features/RestoreEntityInheritedFields.spec.ts › Validate restore with Inherited domain and data products assigned (shard 3, 2 retries)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Pages/Customproperties-part2.spec.ts › entityReferenceList shows item count, scrollable list, no expand toggle (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Rename domain with subdomains attached verifies subdomain accessibility (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Rename domain with data products attached at domain and subdomain levels (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Rename domain with assets (tables, topics, dashboards) preserves associations (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Comprehensive domain rename with ALL relationships preserved (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Verify Domain entity API calls do not include invalid domains field in glossary term assets (shard 4, 1 retry)
  • Pages/EntityDataConsumer.spec.ts › Glossary Term Add, Update and Remove (shard 5, 1 retry)
  • Pages/Glossary.spec.ts › Add and Remove Assets (shard 5, 1 retry)
  • Pages/Glossary.spec.ts › Column dropdown drag-and-drop functionality for Glossary Terms table (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Stored Procedure (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Data Model (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Worksheet (shard 6, 1 retry)
  • Pages/Lineage/DataAssetLineage.spec.ts › Column lineage for table -> dashboardDataModel (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/UserDetails.spec.ts › Create team with domain and verify visibility of inherited domain in user profile after team removal (shard 6, 1 retry)
  • Pages/Users.spec.ts › Permissions for table details page for Data Consumer (shard 6, 1 retry)
  • Pages/Users.spec.ts › Check permissions for Data Steward (shard 6, 1 retry)
  • VersionPages/EntityVersionPages.spec.ts › Directory (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

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

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants