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

dengzh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 4f35a45f4bb HIVE-29179: Make the RELOAD event backward compatible 
after latest changes via HIVE-28967 (#6058)
4f35a45f4bb is described below

commit 4f35a45f4bbd0210404a2b3436f86308cea8851f
Author: Sai Hemanth Gantasala 
<[email protected]>
AuthorDate: Tue Nov 4 18:47:03 2025 -0800

    HIVE-29179: Make the RELOAD event backward compatible after latest changes 
via HIVE-28967 (#6058)
---
 .../hcatalog/listener/DbNotificationListener.java  |  2 +-
 .../hadoop/hive/metastore/events/ReloadEvent.java  | 34 ++++++++++++++++------
 .../hive/metastore/messaging/MessageBuilder.java   |  6 ++--
 .../hive/metastore/messaging/ReloadMessage.java    | 10 ++++++-
 .../messaging/json/JSONReloadMessage.java          | 16 ++++++++--
 5 files changed, 51 insertions(+), 17 deletions(-)

diff --git 
a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
 
b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
index 755f8bbb6d1..fed4a71a01f 100644
--- 
a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
+++ 
b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
@@ -1023,7 +1023,7 @@ public void 
onDeletePartitionColumnStat(DeletePartitionColumnStatEvent deletePar
   public void onReload(ReloadEvent reloadEvent) throws MetaException {
     Table tableObj = reloadEvent.getTableObj();
     ReloadMessage msg = 
MessageBuilder.getInstance().buildReloadMessage(tableObj,
-            reloadEvent.getPartitions(), reloadEvent.isRefreshEvent());
+        reloadEvent.getPartitionObj(), reloadEvent.getPartitions(), 
reloadEvent.isRefreshEvent());
     NotificationEvent event =
             new NotificationEvent(0, now(), EventType.RELOAD.toString(),
                     msgEncoder.getSerializer().serialize(msg));
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/ReloadEvent.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/ReloadEvent.java
index b50322ccaec..d1089754b10 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/ReloadEvent.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/ReloadEvent.java
@@ -43,6 +43,7 @@
 @InterfaceStability.Stable
 public class ReloadEvent extends ListenerEvent {
     private final Table tableObj;
+    private final Partition ptnObj; // for backward compatibility
     private final List<Partition> ptns;
     private final boolean refreshEvent;
 
@@ -70,17 +71,25 @@ public ReloadEvent(String catName, String db, String table, 
List<List<String>> p
                 this.tableObj.getParameters().putAll(tblParams);
             }
             if (partVals != null) {
-                this.ptns = new ArrayList<>();
-                List<String> part_names = new ArrayList<>();
-                for(List<String> partVal : partVals) {
-                    
part_names.add(Warehouse.makePartName(this.tableObj.getPartitionKeys(), 
partVal));
+                if (partVals.size() == 1) {
+                    this.ptnObj = 
handler.get_partition(MetaStoreUtils.prependNotNullCatToDbName(catName, db),
+                        table, partVals.get(0));
+                    this.ptns = null;
+                } else {
+                    this.ptnObj = null;
+                    this.ptns = new ArrayList<>();
+                    List<String> part_names = new ArrayList<>();
+                    for (List<String> partVal : partVals) {
+                        
part_names.add(Warehouse.makePartName(this.tableObj.getPartitionKeys(), 
partVal));
+                    }
+                    GetPartitionsByNamesRequest partitionsReq = new 
GetPartitionsByNamesRequest(
+                        MetaStoreUtils.prependNotNullCatToDbName(catName, db), 
table);
+                    partitionsReq.setNames(part_names);
+                    partitionsReq.setGet_col_stats(false);
+                    
this.ptns.addAll(handler.get_partitions_by_names_req(partitionsReq).getPartitions());
                 }
-                GetPartitionsByNamesRequest partitionsReq = new 
GetPartitionsByNamesRequest(
-                    MetaStoreUtils.prependNotNullCatToDbName(catName, db), 
table);
-                partitionsReq.setNames(part_names);
-                partitionsReq.setGet_col_stats(false);
-                
this.ptns.addAll(handler.get_partitions_by_names_req(partitionsReq).getPartitions());
             } else {
+                this.ptnObj = null;
                 this.ptns = null;
             }
         } catch (NoSuchObjectException e) {
@@ -104,6 +113,13 @@ public Table getTableObj() {
     /**
      * @return Partition object
      */
+    public Partition getPartitionObj() {
+        return ptnObj;
+    }
+
+    /**
+     * @return List of Partition objects
+     */
     public List<Partition> getPartitions() {
         return ptns;
     }
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
index 239df0e7fec..6a0d0dd93c8 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageBuilder.java
@@ -352,10 +352,10 @@ public CommitCompactionMessage 
buildCommitCompactionMessage(CommitCompactionEven
     return new JSONCommitCompactionMessage(MS_SERVER_URL, 
MS_SERVICE_PRINCIPAL, now(), event);
   }
 
-  public ReloadMessage buildReloadMessage(Table tableObj, List<Partition> 
parts,
-                                          boolean refreshEvent) {
+  public ReloadMessage buildReloadMessage(Table tableObj, Partition partObj,
+      List<Partition> parts, boolean refreshEvent) {
     return new JSONReloadMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL,
-            tableObj, parts, refreshEvent, now());
+            tableObj, partObj, parts, refreshEvent, now());
   }
 
   private long now() {
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/ReloadMessage.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/ReloadMessage.java
index 3f5c09df91c..ae9fae5ca08 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/ReloadMessage.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/ReloadMessage.java
@@ -36,10 +36,18 @@ protected ReloadMessage() {
     public abstract Table getTableObj() throws Exception;
 
     /**
-     * Get the partition object associated with the insert
+     * Get the partition objects associated with the reload
      *
      * @return The Json format of Partition object if the table is partitioned 
else return null.
      */
+    public abstract Partition getPtnObj() throws Exception;
+
+    /**
+     * Get the partition objects associated with the reload
+     *
+     * @return The Iterable Json format of Partition object if the table is 
partitioned
+     * else return null.
+     */
     public abstract Iterable<Partition> getPartitionObjs() throws Exception;
 
     /**
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONReloadMessage.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONReloadMessage.java
index d38eb9d7eba..9cf5baa2c64 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONReloadMessage.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONReloadMessage.java
@@ -41,7 +41,7 @@ public class JSONReloadMessage extends ReloadMessage {
     private Long timestamp;
 
     @JsonProperty
-    private String server, servicePrincipal, db, table, tableObjJson, 
refreshEvent;
+    private String server, servicePrincipal, db, table, tableObjJson, 
ptnObjJson, refreshEvent;
 
     @JsonProperty
     List<String> partitionListJson;
@@ -52,8 +52,8 @@ public class JSONReloadMessage extends ReloadMessage {
     public JSONReloadMessage() {
     }
 
-    public JSONReloadMessage(String server, String servicePrincipal, Table 
tableObj, List<Partition> ptns,
-                             boolean refreshEvent, Long timestamp) {
+    public JSONReloadMessage(String server, String servicePrincipal, Table 
tableObj, Partition ptnObj,
+                             List<Partition> ptns, boolean refreshEvent, Long 
timestamp) {
         this.server = server;
         this.servicePrincipal = servicePrincipal;
 
@@ -66,6 +66,11 @@ public JSONReloadMessage(String server, String 
servicePrincipal, Table tableObj,
 
         try {
             this.tableObjJson = MessageBuilder.createTableObjJson(tableObj);
+            if (null != ptnObj) {
+                this.ptnObjJson = 
MessageBuilder.createPartitionObjJson(ptnObj);
+            } else {
+                this.ptnObjJson = null;
+            }
             if (null != ptns) {
                 this.partitionListJson = new ArrayList<>();
                 Iterator<Partition> iterator = ptns.iterator();
@@ -133,6 +138,11 @@ public Partition apply(@Nullable Object input) {
             });
     }
 
+    @Override
+    public Partition getPtnObj() throws Exception {
+        return ((null == ptnObjJson) ? null : (Partition) 
MessageBuilder.getTObj(ptnObjJson, Partition.class));
+    }
+
     @Override
     public String toString() {
         try {

Reply via email to