dutyu commented on code in PR #21589:
URL: https://github.com/apache/doris/pull/21589#discussion_r1259254506


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/hive/event/AlterDatabaseEvent.java:
##########
@@ -15,34 +15,99 @@
 // specific language governing permissions and limitations
 // under the License.
 
-
 package org.apache.doris.datasource.hive.event;
 
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.datasource.CatalogIf;
+import org.apache.doris.datasource.ExternalCatalog;
+
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import 
org.apache.hadoop.hive.metastore.messaging.json.JSONAlterDatabaseMessage;
 
 import java.util.List;
 
 /**
- * MetastoreEvent for Alter_DATABASE event type
+ * MetastoreEvent for ALTER_DATABASE event type
  */
 public class AlterDatabaseEvent extends MetastoreEvent {
 
+    private final Database dbBefore;
+    private final Database dbAfter;
+
+    // true if this alter event was due to a rename operation
+    private final boolean isRename;
+
+    // for test
+    public AlterDatabaseEvent(long eventId, String catalogName, String dbName, 
boolean isRename) {
+        super(eventId, catalogName, dbName, null);
+        this.isRename = isRename;
+        this.dbBefore = null;
+        this.dbAfter = null;
+    }
+
     private AlterDatabaseEvent(NotificationEvent event,
             String catalogName) {
         super(event, catalogName);
         
Preconditions.checkArgument(getEventType().equals(MetastoreEventType.ALTER_DATABASE));
+
+        try {
+            JSONAlterDatabaseMessage alterDatabaseMessage =
+                    (JSONAlterDatabaseMessage) 
MetastoreEventsProcessor.getMessageDeserializer(event.getMessageFormat())
+                                .getAlterDatabaseMessage(event.getMessage());
+            dbBefore = 
Preconditions.checkNotNull(alterDatabaseMessage.getDbObjBefore());
+            dbAfter = 
Preconditions.checkNotNull(alterDatabaseMessage.getDbObjAfter());
+        } catch (Exception e) {
+            throw new MetastoreNotificationException(
+                    debugString("Unable to parse the alter database message"), 
e);
+        }
+        // this is a rename event if either dbName of before and after object 
changed
+        isRename = !dbBefore.getName().equalsIgnoreCase(dbAfter.getName());
+    }
+
+    private void processRename() throws DdlException {

Review Comment:
   I've searched some hive docs, now hive does not support `rename database` 
statement. But we can reserve the relevant code here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to