zhangbutao commented on code in PR #4995:
URL: https://github.com/apache/hive/pull/4995#discussion_r1449650489


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -221,25 +223,46 @@ private void populateInsertUpdateMap(Map<PartitionInfo, 
ColumnStatistics> statsP
 
   private void updatePartColStatTable(Map<PartColNameInfo, 
MPartitionColumnStatistics> updateMap,
                                           Connection dbConn) throws 
SQLException, MetaException, NoSuchObjectException {
-    PreparedStatement pst = null;
+    Map<String, List<Map.Entry>> updates = new HashMap<>();
     for (Map.Entry entry : updateMap.entrySet()) {
-      PartColNameInfo partColNameInfo = (PartColNameInfo) entry.getKey();
-      Long partId = partColNameInfo.partitionId;
       MPartitionColumnStatistics mPartitionColumnStatistics = 
(MPartitionColumnStatistics) entry.getValue();
-      String update = "UPDATE \"PART_COL_STATS\" SET ";
-      update += 
StatObjectConverter.getUpdatedColumnSql(mPartitionColumnStatistics);
-      update += " WHERE \"PART_ID\" = " + partId + " AND "
-              + " \"COLUMN_NAME\" = " +  
quoteString(mPartitionColumnStatistics.getColName());
-      try {
-        pst = dbConn.prepareStatement(update);
-        
StatObjectConverter.initUpdatedColumnStatement(mPartitionColumnStatistics, pst);
-        LOG.debug("Going to execute update " + update);
-        int numUpdate = pst.executeUpdate();
-        if (numUpdate != 1) {
-          throw new MetaException("Invalid state of  PART_COL_STATS for 
PART_ID " + partId);
+      StringBuilder update = new StringBuilder("UPDATE \"PART_COL_STATS\" SET 
")
+          
.append(StatObjectConverter.getUpdatedColumnSql(mPartitionColumnStatistics))
+          .append(" WHERE \"PART_ID\" = ? AND \"COLUMN_NAME\" = ? AND 
\"ENGINE\" = ?");

Review Comment:
   Same as above. Should we also consider addding `CAT_NAME` field 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to