Skip to content

Fixes #31515: include materialized views in PostgreSQL and Greenplum connectors - #31549

Open
zerafachris wants to merge 1 commit into
open-metadata:mainfrom
zerafachris:fix/postgres-greenplum-materialized-view-ingestion
Open

Fixes #31515: include materialized views in PostgreSQL and Greenplum connectors#31549
zerafachris wants to merge 1 commit into
open-metadata:mainfrom
zerafachris:fix/postgres-greenplum-materialized-view-ingestion

Conversation

@zerafachris

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #31515

The PostgreSQL and Greenplum ingestion connectors do not discover materialized views because two things were missing:

  1. RELKIND_MAP in common_pg_mappings.py had no 'm' entry, so the relkind value returned for materialized views had no mapping to TableType.MaterializedView.
  2. POSTGRES_GET_TABLE_NAMES and GREENPLUM_GET_TABLE_NAMES only filtered on relkind in ('r', 'p', 'f'), which excludes 'm' (materialized view) entirely.

I added "m": TableType.MaterializedView to RELKIND_MAP and extended both queries to include 'm' in the relkind filter. TableType.MaterializedView already exists in the generated schema (used by Snowflake, ClickHouse, BigQuery, and others), so no schema changes are needed.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

The pg_class.relkind column uses 'm' for materialized views per the PostgreSQL catalog docs. The existing comment in both query files already listed m = materialized view but the filter never matched it.

Tests:

Use cases covered

  • PostgreSQL connector correctly discovers materialized views in a schema during ingestion.
  • Greenplum connector correctly discovers materialized views in a schema during ingestion.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: ingestion/tests/unit/topology/database/test_postgres.py
    • test_relkind_map_includes_materialized_view — asserts RELKIND_MAP['m'] == TableType.MaterializedView
    • test_postgres_get_table_names_includes_materialized_view_relkind — asserts POSTGRES_GET_TABLE_NAMES contains 'm'

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable — covered by unit tests above; connector-level integration test would require a live Postgres instance with materialized views.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Verified by code inspection:

  1. Confirmed TableType.MaterializedView exists in metadata.generated.schema.entity.data.table.
  2. Confirmed RELKIND_MAP['m'] resolves to TableType.MaterializedView after change.
  3. Confirmed POSTGRES_GET_TABLE_NAMES now includes 'm' in the relkind in (...) filter.
  4. Confirmed GREENPLUM_GET_TABLE_NAMES now includes 'm' in the relkind in (...) filter.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #31515 above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

AI-generated code — reviewed and validated against OSS contribution guidelines. Submitted by zerafachris.

…m connectors

RELKIND_MAP was missing the 'm' entry for materialized views, and both
POSTGRES_GET_TABLE_NAMES and GREENPLUM_GET_TABLE_NAMES excluded relkind = 'm'
from their filters. As a result, materialized views were never discovered
during ingestion. Adding 'm' → TableType.MaterializedView to the relkind map
and extending the relkind filters in both queries fixes the omission.

Fixes open-metadata#31515

> AI-generated code — reviewed and tested against OSS contribution guidelines.
@zerafachris
zerafachris requested a review from a team as a code owner August 14, 2026 14:29
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot

gitar-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Updates PostgreSQL and Greenplum connectors to discover materialized views by mapping the 'm' relkind and including it in table queries. 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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostgreSQL and Greenplum connectors do not discover materialized views with SQLAlchemy 2.x

1 participant