Skip to content

[#11001] feat(catalog-jdbc): Add view create/alter/drop support for MySQL and PostgreSQL catalogs - #11208

Closed
sachinnn99 wants to merge 4 commits into
apache:mainfrom
sachinnn99:feat/11001-jdbc-view-write
Closed

[#11001] feat(catalog-jdbc): Add view create/alter/drop support for MySQL and PostgreSQL catalogs#11208
sachinnn99 wants to merge 4 commits into
apache:mainfrom
sachinnn99:feat/11001-jdbc-view-write

Conversation

@sachinnn99

@sachinnn99 sachinnn99 commented May 24, 2026

Copy link
Copy Markdown
Contributor

Depends on: #11207 (view list/load support). Please review and merge #11207 first.
Note: This PR is rebased on top of #11207. The GitHub diff includes both PRs since the base branch is main. The incremental write-only changes are ~1300 lines.

What changes were proposed in this pull request?

Add write view operations (createView, alterView, dropView) for JDBC catalogs covering MySQL and PostgreSQL. This is the second of two PRs split from #11123, stacked on #11207 (read operations).

Key changes:

  • Add create, replaceDefinition, rename, drop methods to JdbcViewOperations
  • Add createView, alterView, dropView to JdbcViewCatalogOperations
  • Add write SQL generation to MysqlViewOperations and PostgreSqlViewOperations
  • Wire write methods into MysqlCatalogOperations and PostgreSQLCatalogOperations
  • Add setComment support for PostgreSQL views via COMMENT ON VIEW

Includes review fixes:

  • replaceDefinition checks view existence before executing CREATE OR REPLACE VIEW
  • extractSqlRepresentation prefers matching dialect when multiple representations are provided
  • schemaExists catches NoSuchSchemaException instead of broad Exception
  • Safe stream-based SQLRepresentation[] conversion instead of direct array cast

Why are the changes needed?

Completes the JDBC view CRUD support started in #11207. Users can now create, rename, replace, and drop views through the Gravitino API for MySQL and PostgreSQL catalogs.

Fix: #11001

Does this PR introduce any user-facing change?

Yes. catalog.asViewCatalog().createView(), alterView(), and dropView() now work for MySQL and PostgreSQL JDBC catalogs.

How was this patch tested?

  • Unit tests: Extended TestJdbcViewCatalogOperations, TestMysqlViewOperations, TestPostgreSqlViewOperations with write operation tests
  • Integration tests: CatalogMysqlViewWriteIT, CatalogPostgreSqlViewWriteIT (test create/alter/drop through Gravitino API against Docker containers)

Known Limitations

  • MySQL view comments: MySQL does not support view-level comments via DDL. Comments passed to createView() are silently discarded on MySQL.
  • PostgreSQL comment round-trip: Comments are set via COMMENT ON VIEW but loadView() does not read them back from pg_description. Follow-up item.
  • Non-transactional alterView: Changes are applied sequentially without a transaction. Unlike alterTable (which batches non-rename changes into a single SQL and forbids mixing rename with other changes), alterView applies each change as a separate SQL statement and allows rename to be combined with other changes. The validation pass rejects unsupported changes before any are applied.

@sachinnn99
sachinnn99 force-pushed the feat/11001-jdbc-view-write branch from d310092 to ffc7f0e Compare May 27, 2026 09:44
…view load

Add loadComment() template method to JdbcViewOperations so the load
path populates JdbcView.comment(). PostgreSQL overrides it to query
pg_description via obj_description(); MySQL returns null since views
have no comment support.
…ew support

- Load view comments from pg_description via obj_description() in
  PostgreSQL, resolving the comment round-trip gap
- Add loadComment() template method to JdbcViewOperations base class
- Strengthen IT type assertions to verify actual mapped types
- Add reverse-order alter test (replace-then-rename)
@sachinnn99
sachinnn99 force-pushed the feat/11001-jdbc-view-write branch from 4786a76 to 1db83ed Compare May 28, 2026 15:03
@sachinnn99 sachinnn99 closed this May 29, 2026
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.

[Subtask] support write view operations (create/allter) for JDBC catalogs

1 participant