This is an automated email from the ASF dual-hosted git repository.

jshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 889b4750e [#5319] feat(core): add table pre event to Gravitino event 
(#5539)
889b4750e is described below

commit 889b4750e9e27d5abfb613b0e12ae4e6087778e6
Author: FANNG <[email protected]>
AuthorDate: Tue Nov 12 14:47:37 2024 +0800

    [#5319] feat(core): add table pre event to Gravitino event (#5539)
    
    ### What changes were proposed in this pull request?
    
    add table pre event to event listener
    
    
    ### Why are the changes needed?
    
    Fix: #5319
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    add UT
---
 .../gravitino/listener/TableEventDispatcher.java   | 37 ++++++++++++------
 .../listener/api/event/AlterTablePreEvent.java     | 45 ++++++++++++++++++++++
 .../listener/api/event/CreateTablePreEvent.java    | 45 ++++++++++++++++++++++
 .../listener/api/event/DropTablePreEvent.java      | 31 +++++++++++++++
 .../listener/api/event/ListTablePreEvent.java      | 44 +++++++++++++++++++++
 .../listener/api/event/LoadTablePreEvent.java      | 31 +++++++++++++++
 .../listener/api/event/PurgeTablePreEvent.java     | 31 +++++++++++++++
 .../listener/api/event/TablePreEvent.java          | 31 +++++++++++++++
 .../gravitino/listener/DummyEventListener.java     |  5 +++
 .../listener/api/event/TestTableEvent.java         | 35 +++++++++++++++++
 docs/gravitino-server-config.md                    |  3 +-
 11 files changed, 325 insertions(+), 13 deletions(-)

diff --git 
a/core/src/main/java/org/apache/gravitino/listener/TableEventDispatcher.java 
b/core/src/main/java/org/apache/gravitino/listener/TableEventDispatcher.java
index 3eaab19c9..5ce39f9ee 100644
--- a/core/src/main/java/org/apache/gravitino/listener/TableEventDispatcher.java
+++ b/core/src/main/java/org/apache/gravitino/listener/TableEventDispatcher.java
@@ -29,16 +29,22 @@ import org.apache.gravitino.exceptions.NoSuchTableException;
 import org.apache.gravitino.exceptions.TableAlreadyExistsException;
 import org.apache.gravitino.listener.api.event.AlterTableEvent;
 import org.apache.gravitino.listener.api.event.AlterTableFailureEvent;
+import org.apache.gravitino.listener.api.event.AlterTablePreEvent;
 import org.apache.gravitino.listener.api.event.CreateTableEvent;
 import org.apache.gravitino.listener.api.event.CreateTableFailureEvent;
+import org.apache.gravitino.listener.api.event.CreateTablePreEvent;
 import org.apache.gravitino.listener.api.event.DropTableEvent;
 import org.apache.gravitino.listener.api.event.DropTableFailureEvent;
+import org.apache.gravitino.listener.api.event.DropTablePreEvent;
 import org.apache.gravitino.listener.api.event.ListTableEvent;
 import org.apache.gravitino.listener.api.event.ListTableFailureEvent;
+import org.apache.gravitino.listener.api.event.ListTablePreEvent;
 import org.apache.gravitino.listener.api.event.LoadTableEvent;
 import org.apache.gravitino.listener.api.event.LoadTableFailureEvent;
+import org.apache.gravitino.listener.api.event.LoadTablePreEvent;
 import org.apache.gravitino.listener.api.event.PurgeTableEvent;
 import org.apache.gravitino.listener.api.event.PurgeTableFailureEvent;
+import org.apache.gravitino.listener.api.event.PurgeTablePreEvent;
 import org.apache.gravitino.listener.api.info.TableInfo;
 import org.apache.gravitino.rel.Column;
 import org.apache.gravitino.rel.Table;
@@ -56,6 +62,7 @@ import org.apache.gravitino.utils.PrincipalUtils;
  * for event-driven workflows or monitoring of table operations.
  */
 public class TableEventDispatcher implements TableDispatcher {
+
   private final EventBus eventBus;
   private final TableDispatcher dispatcher;
 
@@ -73,6 +80,7 @@ public class TableEventDispatcher implements TableDispatcher {
 
   @Override
   public NameIdentifier[] listTables(Namespace namespace) throws 
NoSuchSchemaException {
+    eventBus.dispatchEvent(new 
ListTablePreEvent(PrincipalUtils.getCurrentUserName(), namespace));
     try {
       NameIdentifier[] nameIdentifiers = dispatcher.listTables(namespace);
       eventBus.dispatchEvent(new 
ListTableEvent(PrincipalUtils.getCurrentUserName(), namespace));
@@ -86,6 +94,7 @@ public class TableEventDispatcher implements TableDispatcher {
 
   @Override
   public Table loadTable(NameIdentifier ident) throws NoSuchTableException {
+    eventBus.dispatchEvent(new 
LoadTablePreEvent(PrincipalUtils.getCurrentUserName(), ident));
     try {
       Table table = dispatcher.loadTable(ident);
       eventBus.dispatchEvent(
@@ -109,6 +118,19 @@ public class TableEventDispatcher implements 
TableDispatcher {
       SortOrder[] sortOrders,
       Index[] indexes)
       throws NoSuchSchemaException, TableAlreadyExistsException {
+    TableInfo createTableRequest =
+        new TableInfo(
+            ident.name(),
+            columns,
+            comment,
+            properties,
+            partitions,
+            distribution,
+            sortOrders,
+            indexes,
+            null);
+    eventBus.dispatchEvent(
+        new CreateTablePreEvent(PrincipalUtils.getCurrentUserName(), ident, 
createTableRequest));
     try {
       Table table =
           dispatcher.createTable(
@@ -117,17 +139,6 @@ public class TableEventDispatcher implements 
TableDispatcher {
           new CreateTableEvent(PrincipalUtils.getCurrentUserName(), ident, new 
TableInfo(table)));
       return table;
     } catch (Exception e) {
-      TableInfo createTableRequest =
-          new TableInfo(
-              ident.name(),
-              columns,
-              comment,
-              properties,
-              partitions,
-              distribution,
-              sortOrders,
-              indexes,
-              null);
       eventBus.dispatchEvent(
           new CreateTableFailureEvent(
               PrincipalUtils.getCurrentUserName(), ident, e, 
createTableRequest));
@@ -138,6 +149,8 @@ public class TableEventDispatcher implements 
TableDispatcher {
   @Override
   public Table alterTable(NameIdentifier ident, TableChange... changes)
       throws NoSuchTableException, IllegalArgumentException {
+    eventBus.dispatchEvent(
+        new AlterTablePreEvent(PrincipalUtils.getCurrentUserName(), ident, 
changes));
     try {
       Table table = dispatcher.alterTable(ident, changes);
       eventBus.dispatchEvent(
@@ -153,6 +166,7 @@ public class TableEventDispatcher implements 
TableDispatcher {
 
   @Override
   public boolean dropTable(NameIdentifier ident) {
+    eventBus.dispatchEvent(new 
DropTablePreEvent(PrincipalUtils.getCurrentUserName(), ident));
     try {
       boolean isExists = dispatcher.dropTable(ident);
       eventBus.dispatchEvent(
@@ -167,6 +181,7 @@ public class TableEventDispatcher implements 
TableDispatcher {
 
   @Override
   public boolean purgeTable(NameIdentifier ident) {
+    eventBus.dispatchEvent(new 
PurgeTablePreEvent(PrincipalUtils.getCurrentUserName(), ident));
     try {
       boolean isExists = dispatcher.purgeTable(ident);
       eventBus.dispatchEvent(
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTablePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTablePreEvent.java
new file mode 100644
index 000000000..4207b5447
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTablePreEvent.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.rel.TableChange;
+
+/** Represents an event triggered before altering a table. */
+@DeveloperApi
+public class AlterTablePreEvent extends TablePreEvent {
+  private final TableChange[] tableChanges;
+
+  public AlterTablePreEvent(String user, NameIdentifier identifier, 
TableChange[] tableChanges) {
+    super(user, identifier);
+    this.tableChanges = tableChanges;
+  }
+
+  /**
+   * Retrieves the specific changes that were made to the table during the 
alteration process.
+   *
+   * @return An array of {@link TableChange} objects detailing each 
modification applied to the
+   *     table.
+   */
+  public TableChange[] tableChanges() {
+    return tableChanges;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTablePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTablePreEvent.java
new file mode 100644
index 000000000..40e8ce421
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTablePreEvent.java
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.info.TableInfo;
+
+/** Represents an event triggered before creating a table. */
+@DeveloperApi
+public class CreateTablePreEvent extends TablePreEvent {
+  private final TableInfo createTableRequest;
+
+  public CreateTablePreEvent(String user, NameIdentifier identifier, TableInfo 
createTableRequest) {
+    super(user, identifier);
+    this.createTableRequest = createTableRequest;
+  }
+
+  /**
+   * Retrieves the create table request.
+   *
+   * @return A {@link TableInfo} instance encapsulating the comprehensive 
details of create table
+   *     request.
+   */
+  public TableInfo createTableRequest() {
+    return createTableRequest;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DropTablePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DropTablePreEvent.java
new file mode 100644
index 000000000..3b1954090
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DropTablePreEvent.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered before dropping a table. */
+@DeveloperApi
+public class DropTablePreEvent extends TablePreEvent {
+  public DropTablePreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTablePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTablePreEvent.java
new file mode 100644
index 000000000..f26d88f84
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTablePreEvent.java
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered before listing of tables within a 
namespace. */
+@DeveloperApi
+public class ListTablePreEvent extends TablePreEvent {
+  private final Namespace namespace;
+
+  public ListTablePreEvent(String user, Namespace namespace) {
+    super(user, NameIdentifier.of(namespace.levels()));
+    this.namespace = namespace;
+  }
+
+  /**
+   * Provides the namespace associated with this event.
+   *
+   * @return A {@link Namespace} instance from which tables were listed.
+   */
+  public Namespace namespace() {
+    return namespace;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/LoadTablePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/LoadTablePreEvent.java
new file mode 100644
index 000000000..c60830ea4
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/LoadTablePreEvent.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event triggered before loading a table. */
+@DeveloperApi
+public class LoadTablePreEvent extends TablePreEvent {
+  public LoadTablePreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/PurgeTablePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/PurgeTablePreEvent.java
new file mode 100644
index 000000000..908ea9c70
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/PurgeTablePreEvent.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event triggered before purging a table. */
+@DeveloperApi
+public class PurgeTablePreEvent extends TablePreEvent {
+  public PurgeTablePreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/TablePreEvent.java 
b/core/src/main/java/org/apache/gravitino/listener/api/event/TablePreEvent.java
new file mode 100644
index 000000000..be6a1775b
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/TablePreEvent.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents a pre-event for table operations. */
+@DeveloperApi
+public abstract class TablePreEvent extends PreEvent {
+  protected TablePreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+}
diff --git 
a/core/src/test/java/org/apache/gravitino/listener/DummyEventListener.java 
b/core/src/test/java/org/apache/gravitino/listener/DummyEventListener.java
index 4ec7ab715..2e34362ad 100644
--- a/core/src/test/java/org/apache/gravitino/listener/DummyEventListener.java
+++ b/core/src/test/java/org/apache/gravitino/listener/DummyEventListener.java
@@ -72,6 +72,11 @@ public class DummyEventListener implements 
EventListenerPlugin {
     return postEvents.removeLast();
   }
 
+  public PreEvent popPreEvent() {
+    Assertions.assertTrue(preEvents.size() > 0, "No events to pop");
+    return preEvents.removeLast();
+  }
+
   public static class DummyAsyncEventListener extends DummyEventListener {
     public List<Event> tryGetPostEvents() {
       Awaitility.await()
diff --git 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestTableEvent.java
 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestTableEvent.java
index 11507c343..2ea2d3a1e 100644
--- 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestTableEvent.java
+++ 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestTableEvent.java
@@ -84,22 +84,34 @@ public class TestTableEvent {
         table.distribution(),
         table.sortOrder(),
         table.index());
+
     Event event = dummyEventListener.popPostEvent();
     Assertions.assertEquals(identifier, event.identifier());
     Assertions.assertEquals(CreateTableEvent.class, event.getClass());
     TableInfo tableInfo = ((CreateTableEvent) event).createdTableInfo();
     checkTableInfo(tableInfo, table);
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(CreateTablePreEvent.class, preEvent.getClass());
+    tableInfo = ((CreateTablePreEvent) preEvent).createTableRequest();
+    checkTableInfo(tableInfo, table);
   }
 
   @Test
   void testLoadTableEvent() {
     NameIdentifier identifier = NameIdentifier.of("metalake", "catalog", 
table.name());
     dispatcher.loadTable(identifier);
+
     Event event = dummyEventListener.popPostEvent();
     Assertions.assertEquals(identifier, event.identifier());
     Assertions.assertEquals(LoadTableEvent.class, event.getClass());
     TableInfo tableInfo = ((LoadTableEvent) event).loadedTableInfo();
     checkTableInfo(tableInfo, table);
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(LoadTablePreEvent.class, preEvent.getClass());
   }
 
   @Test
@@ -107,6 +119,7 @@ public class TestTableEvent {
     NameIdentifier identifier = NameIdentifier.of("metalake", "catalog", 
table.name());
     TableChange change = TableChange.setProperty("a", "b");
     dispatcher.alterTable(identifier, change);
+
     Event event = dummyEventListener.popPostEvent();
     Assertions.assertEquals(identifier, event.identifier());
     Assertions.assertEquals(AlterTableEvent.class, event.getClass());
@@ -114,36 +127,58 @@ public class TestTableEvent {
     checkTableInfo(tableInfo, table);
     Assertions.assertEquals(1, ((AlterTableEvent) 
event).tableChanges().length);
     Assertions.assertEquals(change, ((AlterTableEvent) 
event).tableChanges()[0]);
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(AlterTablePreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(1, ((AlterTablePreEvent) 
preEvent).tableChanges().length);
+    Assertions.assertEquals(change, ((AlterTablePreEvent) 
preEvent).tableChanges()[0]);
   }
 
   @Test
   void testDropTableEvent() {
     NameIdentifier identifier = NameIdentifier.of("metalake", "catalog", 
table.name());
     dispatcher.dropTable(identifier);
+
     Event event = dummyEventListener.popPostEvent();
     Assertions.assertEquals(identifier, event.identifier());
     Assertions.assertEquals(DropTableEvent.class, event.getClass());
     Assertions.assertEquals(true, ((DropTableEvent) event).isExists());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(DropTablePreEvent.class, preEvent.getClass());
   }
 
   @Test
   void testPurgeTableEvent() {
     NameIdentifier identifier = NameIdentifier.of("metalake", "catalog", 
table.name());
     dispatcher.purgeTable(identifier);
+
     Event event = dummyEventListener.popPostEvent();
     Assertions.assertEquals(identifier, event.identifier());
     Assertions.assertEquals(PurgeTableEvent.class, event.getClass());
     Assertions.assertEquals(true, ((PurgeTableEvent) event).isExists());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(PurgeTablePreEvent.class, preEvent.getClass());
   }
 
   @Test
   void testListTableEvent() {
     Namespace namespace = Namespace.of("metalake", "catalog");
     dispatcher.listTables(namespace);
+
     Event event = dummyEventListener.popPostEvent();
     Assertions.assertEquals(namespace.toString(), 
event.identifier().toString());
     Assertions.assertEquals(ListTableEvent.class, event.getClass());
     Assertions.assertEquals(namespace, ((ListTableEvent) event).namespace());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(namespace.toString(), 
preEvent.identifier().toString());
+    Assertions.assertEquals(ListTablePreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(namespace, ((ListTablePreEvent) 
preEvent).namespace());
   }
 
   @Test
diff --git a/docs/gravitino-server-config.md b/docs/gravitino-server-config.md
index d9eb48977..b3b555885 100644
--- a/docs/gravitino-server-config.md
+++ b/docs/gravitino-server-config.md
@@ -129,11 +129,10 @@ Gravitino triggers a pre-event before the operation, a 
post-event after the comp
 
 ##### Pre-event
 
-Pre-event is only generated before Iceberg REST server table operations, the 
other operation doesn't generate pre-event for now.
-
 | Operation type                      | Pre-event                              
                                                                                
                                                                                
    | Since Version    |
 
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|
 | Iceberg REST server table operation | `IcebergCreateTablePreEvent`, 
`IcebergUpdateTablePreEvent`, `IcebergDropTablePreEvent`, 
`IcebergLoadTablePreEvent`, `IcebergListTablePreEvent`, 
`IcebergTableExistsPreEvent`, `IcebergRenameTablePreEvent` | 0.7.0-incubating |
+| Gravitino server table operation    | `CreateTablePreEvent`, 
`UpdateTablePreEvent`, `DropTablePreEvent`, `PurgeTablePreEvent`, 
`LoadTablePreEvent`, `ListTablePreEvent`                                        
                                  | 0.8.0-incubating |
 
 #### Event listener plugin
 

Reply via email to