soumyakanti3578 commented on code in PR #6287:
URL: https://github.com/apache/hive/pull/6287#discussion_r2775621506


##########
itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestReplChangeManager.java:
##########
@@ -249,6 +249,7 @@ public void testRecycleNonPartTable() throws Exception {
     db.putToParameters(SOURCE_OF_REPLICATION, "1, 2, 3");
     db.setName(dbName);
     client.createDatabase(db);
+    db = client.getDatabase(dbName);

Review Comment:
   This part is a bit confusing to me as we are assigning a new instance to the 
variable `db` twice. Is it possible to clean this up? Maybe something like:
   `Database db = client.createDatabase(req:CreateDatabaseRequest)`
   
   This may require new APIs, so I will leave the decision up to you!



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -918,11 +910,12 @@ public void create_catalog(CreateCatalogRequest rqst)
         ms.createCatalog(catalog);
 
         // Create a default database inside the catalog
-        Database db = new Database(DEFAULT_DATABASE_NAME,
-            "Default database for catalog " + catalog.getName(), 
catalog.getLocationUri(),
-            Collections.emptyMap());
-        db.setCatalogName(catalog.getName());
-        create_database_core(ms, db);
+        CreateDatabaseRequest cdr = new 
CreateDatabaseRequest(DEFAULT_DATABASE_NAME);
+        cdr.setCatalogName(catalog.getName());
+        cdr.setLocationUri(catalog.getLocationUri());
+        cdr.setParameters(Collections.emptyMap());
+        cdr.setDescription("Default database for catalog " + 
catalog.getName());
+        success |= AbstractRequestHandler.offer(this, cdr).success();

Review Comment:
   I am just trying to understand why do we need `|=` here? Before this 
`success = false`, so I don't think we need an `OR` here. We may need an `OR` 
later when committing though?
   `success |= ms.commitTransaction();`
   
   That way finally block will be dependent on the success of both API calls?



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -949,9 +942,10 @@ public void create_catalog(CreateCatalogRequest rqst)
         }
       }
       success = true;
-    } catch (AlreadyExistsException|InvalidObjectException|MetaException e) {
-      ex = e;
-      throw e;
+    } catch (Exception e) {

Review Comment:
   I think copilot is right here and you are missing `ex = e` since it's there 
in other places too? 



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -7437,213 +7042,32 @@ public AggrStats 
get_aggr_stats_for(PartitionsStatsRequest request) throws TExce
   }
 
   @Override
-  public boolean set_aggr_stats_for(SetPartitionsStatsRequest request) throws 
TException {
-    boolean ret = true;
-    List<ColumnStatistics> csNews = request.getColStats();
-    if (csNews == null || csNews.isEmpty()) {
-      return ret;
+  public boolean set_aggr_stats_for(SetPartitionsStatsRequest req) throws 
TException {
+    List<ColumnStatistics> columnStatisticsList = req.getColStats();
+    if (columnStatisticsList == null || columnStatisticsList.isEmpty()) {
+      return true;
     }
-    // figure out if it is table level or partition level
-    ColumnStatistics firstColStats = csNews.get(0);
-    ColumnStatisticsDesc statsDesc = firstColStats.getStatsDesc();
+    ColumnStatisticsDesc statsDesc = 
columnStatisticsList.get(0).getStatsDesc();

Review Comment:
   nit: can we use `getFirst()` instead of `get(0)` here? 
   
   There are other places with `get(0)` too, but it's up to you if you want to 
change these :) 



-- 
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