Skip to content

Add view CRUD event dispatching, hooks, audit mapping, and tests#11028

Open
raushanprabhakar1 wants to merge 3 commits into
apache:mainfrom
raushanprabhakar1:feat-11002
Open

Add view CRUD event dispatching, hooks, audit mapping, and tests#11028
raushanprabhakar1 wants to merge 3 commits into
apache:mainfrom
raushanprabhakar1:feat-11002

Conversation

@raushanprabhakar1
Copy link
Copy Markdown

What changes were proposed in this pull request?

  • Introduce ViewInfo and view event types (pre/success/failure) for list, load, create, alter, and drop, aligned with existing OperationType view entries.
  • Add ViewEventDispatcher to emit those events on the EventBus, and ViewHookDispatcher for ownership on create, privilege rename on view rename, and privilege cleanup on drop (mirroring table behavior).
  • Wire GravitinoEnv so the view stack is ViewHookDispatcherViewEventDispatcherViewNormalizeDispatcherViewOperationDispatcher.
  • Map the new events in AuditLog.Operation.fromEvent so audit logs are not UNKNOWN_OPERATION for view ops.
  • Add TestViewEvent and extend TestOperation for audit mapping.

Why are the changes needed?

View operations did not go through the same listener and hook chain as tables, so EventListenerPlugin implementations could not observe view CRUD and audit could not classify view events. This addresses the subtask for table-style view event hooks.

Fix: #11002

Does this PR introduce any user-facing change?

Yes. Event listeners and audit integrations now receive view CRUD events (and related audit operation types). No REST or client API surface changes; viewExists remains without dedicated events, consistent with tableExists.

How was this patch tested?

  • ./gradlew :core:spotlessApply :core:test --tests org.apache.gravitino.listener.api.event.TestViewEvent --tests org.apache.gravitino.audit.TestOperation -PskipITs

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 brings view CRUD operations in line with existing table behavior by adding an event + hook dispatch chain for views and ensuring audit log classification recognizes the new view events.

Changes:

  • Added ViewInfo plus pre/success/failure view event types and a ViewEventDispatcher to emit them on the EventBus.
  • Added ViewHookDispatcher to apply ownership and authorization-related hooks for view create/rename/drop.
  • Wired the view dispatcher chain in GravitinoEnv and updated AuditLog.Operation.fromEvent + tests to cover audit mapping for view events.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
core/src/test/java/org/apache/gravitino/listener/api/event/TestViewEvent.java New unit tests validating view pre/post/failure event emission.
core/src/test/java/org/apache/gravitino/audit/TestOperation.java Extends audit-mapping tests to cover view operations.
core/src/main/java/org/apache/gravitino/listener/ViewEventDispatcher.java New dispatcher that emits view CRUD events around view operations.
core/src/main/java/org/apache/gravitino/listener/api/info/ViewInfo.java New listener-facing view info DTO used in view events.
core/src/main/java/org/apache/gravitino/listener/api/event/ViewPreEvent.java Base pre-event type for view operations.
core/src/main/java/org/apache/gravitino/listener/api/event/ViewFailureEvent.java Base failure-event type for view operations.
core/src/main/java/org/apache/gravitino/listener/api/event/ViewEvent.java Base success-event type for view operations.
core/src/main/java/org/apache/gravitino/listener/api/event/LoadViewPreEvent.java Pre-event for load-view.
core/src/main/java/org/apache/gravitino/listener/api/event/LoadViewFailureEvent.java Failure-event for load-view.
core/src/main/java/org/apache/gravitino/listener/api/event/LoadViewEvent.java Success-event for load-view.
core/src/main/java/org/apache/gravitino/listener/api/event/ListViewPreEvent.java Pre-event for list-views.
core/src/main/java/org/apache/gravitino/listener/api/event/ListViewFailureEvent.java Failure-event for list-views.
core/src/main/java/org/apache/gravitino/listener/api/event/ListViewEvent.java Success-event for list-views.
core/src/main/java/org/apache/gravitino/listener/api/event/DropViewPreEvent.java Pre-event for drop-view.
core/src/main/java/org/apache/gravitino/listener/api/event/DropViewFailureEvent.java Failure-event for drop-view.
core/src/main/java/org/apache/gravitino/listener/api/event/DropViewEvent.java Success-event for drop-view.
core/src/main/java/org/apache/gravitino/listener/api/event/CreateViewPreEvent.java Pre-event for create-view.
core/src/main/java/org/apache/gravitino/listener/api/event/CreateViewFailureEvent.java Failure-event for create-view.
core/src/main/java/org/apache/gravitino/listener/api/event/CreateViewEvent.java Success-event for create-view.
core/src/main/java/org/apache/gravitino/listener/api/event/AlterViewPreEvent.java Pre-event for alter-view.
core/src/main/java/org/apache/gravitino/listener/api/event/AlterViewFailureEvent.java Failure-event for alter-view.
core/src/main/java/org/apache/gravitino/listener/api/event/AlterViewEvent.java Success-event for alter-view.
core/src/main/java/org/apache/gravitino/hook/ViewHookDispatcher.java New hook dispatcher for ownership and privilege rename/cleanup on view ops.
core/src/main/java/org/apache/gravitino/GravitinoEnv.java Wires the view dispatcher chain (hook → event → normalize → operation).
core/src/main/java/org/apache/gravitino/audit/AuditLog.java Maps view events to concrete audit operations instead of UNKNOWN.

@github-actions
Copy link
Copy Markdown

Code Coverage Report

Overall Project 66.04% +0.02% 🟢
Files changed 68.05% 🟢

Module Coverage
aliyun 1.73% 🔴
api 47.13% 🟢
authorization-common 85.96% 🟢
aws 1.1% 🔴
azure 2.6% 🔴
catalog-common 10.2% 🔴
catalog-fileset 80.02% 🟢
catalog-glue 82.47% 🟢
catalog-hive 81.83% 🟢
catalog-jdbc-clickhouse 79.18% 🟢
catalog-jdbc-common 43.93% 🟢
catalog-jdbc-doris 80.28% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.23% 🟢
catalog-jdbc-oceanbase 78.38% 🟢
catalog-jdbc-postgresql 82.05% 🟢
catalog-jdbc-starrocks 78.27% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 45.14% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 87.08% 🟢
catalog-lakehouse-paimon 76.85% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 77.96% 🟢
common 50.01% 🟢
core 82.26% -0.36% 🟢
filesystem-hadoop3 76.97% 🟢
flink 42.86% 🟢
flink-runtime 0.0% 🔴
gcp 14.2% 🔴
hadoop-common 10.39% 🔴
hive-metastore-common 46.83% 🟢
iceberg-common 55.24% 🟢
iceberg-rest-server 69.6% 🟢
idp-basic 94.68% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 19.95% 🔴
lance-rest-server 62.78% 🟢
lineage 53.02% 🟢
optimizer 82.95% 🟢
optimizer-api 21.95% 🔴
server 85.78% 🟢
server-common 71.21% 🟢
spark 32.79% 🔴
spark-common 39.09% 🔴
trino-connector 35.14% 🔴
Files
Module File Coverage
core AlterViewEvent.java 100.0% 🟢
AlterViewFailureEvent.java 100.0% 🟢
AlterViewPreEvent.java 100.0% 🟢
CreateViewEvent.java 100.0% 🟢
CreateViewFailureEvent.java 100.0% 🟢
CreateViewPreEvent.java 100.0% 🟢
DropViewEvent.java 100.0% 🟢
DropViewFailureEvent.java 100.0% 🟢
DropViewPreEvent.java 100.0% 🟢
ListViewEvent.java 100.0% 🟢
ListViewFailureEvent.java 100.0% 🟢
ListViewPreEvent.java 100.0% 🟢
LoadViewEvent.java 100.0% 🟢
LoadViewFailureEvent.java 100.0% 🟢
LoadViewPreEvent.java 100.0% 🟢
ViewEvent.java 100.0% 🟢
ViewFailureEvent.java 100.0% 🟢
ViewPreEvent.java 100.0% 🟢
ViewInfo.java 100.0% 🟢
ViewEventDispatcher.java 98.15% 🟢
AuditLog.java 97.48% 🟢
GravitinoEnv.java 11.24% 🔴
ViewHookDispatcher.java 0.0% 🔴

raushanprabhakar1 and others added 2 commits May 14, 2026 17:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@raushanprabhakar1
Copy link
Copy Markdown
Author

Hi @mchades requesting a review from you, Thanks

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] Event listener for view operations

2 participants