Skip to content

fix(glue): stop a custom databaseName dropping every schema - #31958

Open
mohittilala wants to merge 5 commits into
mainfrom
fix/11571-glue-databasename-empty-ingestion
Open

fix(glue): stop a custom databaseName dropping every schema#31958
mohittilala wants to merge 5 commits into
mainfrom
fix/11571-glue-databasename-empty-ingestion

Conversation

@mohittilala

@mohittilala mohittilala commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fixes open-metadata/openmetadata-collate#5942

Summary

Setting the Glue databaseName produced a successful ingestion with zero schemas and zero tables.

get_database_names yields the configured databaseName verbatim, and get_database_schema_names then filtered with schema.CatalogId != database_name, comparing that label against the Glue Catalog ID (the AWS account ID). Unless the user happened to type their own account ID into the field, nothing matched, every schema was skipped, and the run still reported Success with no failures and no warnings.

The comparison came from #26908, which is correct for the default path where the OpenMetadata database really is the Catalog ID. It was applied to the custom-name path too, where it can never hold.

What this changes

databaseName is a label for the OpenMetadata database, not a selector for a Glue catalog, which is how the field behaves across connectors. So when it is set there is exactly one database and every visible Glue database is one of its schemas, and there is nothing to scope by Catalog ID. When it is unset nothing changes: the database is the Catalog ID and schemas from other catalogs still belong elsewhere.

A previous attempt at this (#31820, closed unmerged) made the same call conditional, and review raised that it dropped catalog scoping altogether, so schemas with the same name in different catalogs could silently collide under one database. Rather than invent a scoping rule the field never promised, this reports the situation: if schemas from more than one Catalog ID actually land in the database, the run records a warning naming the catalogs and telling the user to clear the field to get one database per catalog.

Also corrects the glueConnection.json description for the field. It claimed the default is default, while the code uses the Glue Catalog ID and yaml.mdx already says so. That description is the tooltip in the Add Service form, so the wrong version was the one users read.

Validation

  • pytest -c ingestion/pyproject.toml ingestion/tests/unit/topology/database/test_glue.py -q, 11 passed
  • pytest -c ingestion/pyproject.toml ingestion/tests/unit/topology/database/ -q, 1217 passed
  • basedpyright on the changed source, 0 errors and 0 warnings, no new entries against the violation baseline
  • ruff check and ruff format --check on the changed files

Reproduced first by driving the real get_database_names into get_database_schema_names sequence against the connector's own fixtures:

before   [databaseName unset]    databases=['118146679784']  schemas=['default','mydatabase','testdatalake_db','zipcode-db']
before   [databaseName=NEW_DB]   databases=['NEW_DB']        schemas=[]                 failures=0  warnings=0
after    [databaseName=NEW_DB]   databases=['NEW_DB']        schemas=['default','mydatabase','testdatalake_db','zipcode-db']

Tests

Two regression tests, both of which fail on main:

  • a configured databaseName still discovers every schema, with no failures and no warnings
  • schemas from two catalogs are merged under the one name and the run records a warning

The existing test_database_schema_names_filters_other_catalogs_before_schema_filter from #26908 still passes, so the default path keeps its catalog scoping.

Follow-ups, deliberately not in this PR

  • databaseFilterPattern is not applied to a custom databaseName today. Making it apply would be consistent with other connectors but is a behaviour change beyond this fix.
  • Glue has no catalogId connection field, unlike Athena. That is the proper way to express "ingest this specific catalog" and is a feature rather than a bug fix.
  • docs-om connectors/database/glue/yaml.mdx ships databaseName: database_name in its sample YAML, which used to be exactly the broken case. Harmless now, but the sample should say what the field does.

Greptile Summary

The PR fixes Glue ingestion with a custom databaseName by retaining visible schemas and preserving each uniquely named schema’s catalog identity when retrieving tables.

  • Applies catalog filtering only when the OpenMetadata database name defaults to the Glue Catalog ID.
  • Records schema-to-catalog mappings and passes CatalogId to Glue table pagination.
  • Warns when a custom database merges schemas from multiple catalogs.
  • Corrects the Glue databaseName schema description and regenerates dependent UI models.
  • Adds regression coverage for custom names, multiple catalogs, absent catalog IDs, and catalog-specific table retrieval.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported loss of catalog identity before table retrieval is addressed by retaining each uniquely named schema’s Catalog ID and supplying it to Glue table pagination.

Important Files Changed

Filename Overview
ingestion/src/metadata/ingestion/source/database/glue/metadata.py Correctly separates a custom OpenMetadata database label from Glue catalog filtering and preserves catalog identity for uniquely named schemas during table retrieval.
ingestion/tests/unit/topology/database/test_glue.py Adds focused regression tests for custom database naming, cross-catalog enumeration, warnings, missing catalog IDs, and catalog-aware table pagination.
openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/glueConnection.json Clarifies that databaseName labels the OpenMetadata database and does not select a Glue catalog.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Enumerate Glue databases] --> B{Custom databaseName set?}
  B -- No --> C[Keep schemas matching current Catalog ID]
  B -- Yes --> D[Keep every visible schema]
  C --> E[Record schema CatalogId]
  D --> E
  E --> F[Create OpenMetadata schema]
  F --> G[Request Glue tables with DatabaseName and CatalogId]
  D --> H{Multiple Catalog IDs seen?}
  H -- Yes --> I[Record ingestion warning]
Loading

Reviews (4): Last reviewed commit: "Merge branch 'main' into fix/11571-glue-..." | Re-trigger Greptile

databaseName labels the OpenMetadata database, it does not name a Glue
catalog. Schema discovery compared it against the Glue Catalog ID, so a
custom name matched nothing and every schema was skipped while the run
still reported Success.

Skip that comparison when databaseName is set, since one name means one
database and every visible Glue database is one of its schemas. Warn when
that merges schemas from more than one catalog, so same-named schemas
colliding is visible rather than silent.

Also correct the connection schema description, which claimed the default
database name is "default" while the code uses the Glue Catalog ID.
@mohittilala mohittilala self-assigned this Aug 24, 2026
@mohittilala
mohittilala requested a review from a team as a code owner August 24, 2026 11:33
Copilot AI lite review requested due to automatic review settings August 24, 2026 11:33
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Aug 24, 2026
Comment thread ingestion/src/metadata/ingestion/source/database/glue/metadata.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes Glue ingestion behavior when a custom databaseName is configured, ensuring schemas are not incorrectly dropped due to an invalid CatalogId comparison, and improving user-facing configuration guidance.

Changes:

  • Adjusted Glue schema discovery to only enforce CatalogId scoping when databaseName is not configured.
  • Added regression tests covering custom databaseName schema discovery and multi-catalog warning behavior.
  • Updated the Glue connection JSON schema tooltip/description to correctly explain databaseName semantics and defaults.

Reviewed changes

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

File Description
openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/glueConnection.json Corrects databaseName description to match actual default (Glue Catalog ID) and clarifies it is a display name, not an ingestion selector.
ingestion/src/metadata/ingestion/source/database/glue/metadata.py Fixes schema filtering logic for custom databaseName; adds a warning when multiple CatalogIds are merged under one OpenMetadata database name.
ingestion/tests/unit/topology/database/test_glue.py Adds regression coverage for custom databaseName schema discovery and multi-catalog merge warning.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

Copilot AI review requested due to automatic review settings August 24, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 15 changed files in this pull request and generated 1 comment.

Comment on lines 192 to 200
database_name = self.context.get().database
custom_database_name = self.service_connection.databaseName
catalog_ids_seen = set()
for page in self._get_glue_database_and_schemas() or []:
for schema in page.DatabaseList:
try:
if schema.CatalogId != database_name:
if not custom_database_name and schema.CatalogId != database_name:
continue
schema_fqn = fqn.build(
_get_glue_tables called get_tables with DatabaseName only, so it read from
the caller's default catalog. Now that a schema from another catalog can be
yielded, its tables would come back empty or belong to a same-named database
in the wrong catalog.

Stash each schema's Catalog ID as it is yielded and pass it to get_tables.
The default path is unaffected, since the database there already is the
caller's Catalog ID.
Copilot AI review requested due to automatic review settings August 24, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 15 changed files in this pull request and generated 1 comment.

Comment thread ingestion/src/metadata/ingestion/source/database/glue/metadata.py
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 67%
67.07% (80438/119922) 51.46% (49259/95715) 52.44% (14708/28046)

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 5ae863d440abf906731da6df57273b41d151b843 in Playwright run 32774495047, attempt 1.

✅ 672 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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) 59m 50s

⏱️ Max setup 6m 30s · max shard execution 20m 32s · max shard-job elapsed before upload 25m 37s · reporting 6s

🌐 223.69 requests/attempt · 2.66 app boots/UI scenario · 30.52% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 30.52% (convergence target: at most 15%).
  • Browser traffic was 223.69 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.66 per UI scenario (1870 boots / 702 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 158 0 0 0 0 0
✅ Shard chromium-02 163 0 0 0 0 0
✅ Shard chromium-03 149 0 0 0 0 0
✅ Shard chromium-04 138 0 0 0 0 0
✅ Shard ingestion-01 30 0 0 0 0 0
✅ Shard ingestion-02 34 0 0 0 0 0

📦 Download artifacts

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

@sonarqubecloud

Copy link
Copy Markdown

GlueSchema.CatalogId is Optional, and adding it unguarded put None in the
set used for the merge warning. Sorting that set then raised TypeError
outside the per-schema try/except, so one database without a Catalog ID
aborted schema discovery for the whole service.

Track only non-empty Catalog IDs, reusing the guard the catalog map
already applies.
Copilot AI review requested due to automatic review settings August 24, 2026 20:30
@mohittilala mohittilala added the skip-pr-checks Bypass PR metadata validation check label Aug 24, 2026
@gitar-bot

gitar-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Fixes Glue custom database name ingestion so schemas are no longer filtered out incorrectly, while preserving catalog identity during table lookup and adding multi-catalog warning coverage. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Copilot AI review requested due to automatic review settings August 24, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 15 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

ingestion/src/metadata/ingestion/source/database/glue/metadata.py:224

  • When schema.CatalogId is missing, schema_catalog_id_map is left unchanged. Since this map is reused across schemas (and potentially across multiple Glue catalogs processed by the same source instance), a schema with a missing CatalogId but a name that was previously seen can inherit a stale CatalogId and cause _get_glue_tables() to paginate against the wrong catalog. Consider explicitly clearing any prior mapping for this schema name (e.g., else: self.schema_catalog_id_map.pop(schema.Name, None)) when CatalogId is falsy.
                    if schema.Description:
                        self.schema_description_map[schema.Name] = Markdown(schema.Description)
                    if schema.CatalogId:
                        self.schema_catalog_id_map[schema.Name] = schema.CatalogId
                        catalog_ids_seen.add(schema.CatalogId)

Comment on lines +340 to +342
assert ["default", "foreign_schema"] == list(source.get_database_schema_names()) # noqa: SIM300
assert len(source.status.warnings) == 1
assert "more than one catalog" in str(source.status.warnings[0])
@sonarqubecloud

Copy link
Copy Markdown

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 skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants