difin commented on code in PR #4348:
URL: https://github.com/apache/hive/pull/4348#discussion_r1212499829


##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestMetaStoreServerUtils.java:
##########
@@ -294,6 +297,81 @@ public void testUpdateTableStatsSlow_doesNotUpdateStats() 
throws TException {
     verify(wh, never()).getFileStatusesForUnpartitionedTable(db, tbl2);
   }
 
+  /**
+   * Verify that updateTableStatsForCreateTable() does not invoke calculation 
of table statistics when
+   * <ol>
+   *   <li>the table is an Iceberg table</li>
+   * </ol>
+   */
+  @Test
+  public void testUpdateTableStatsForCreateTable_doesNotInvokeStatsCalc() 
throws TException {
+    // Iceberg table & Iceberg stats source is Iceberg => doesn't invokes 
stats calculation
+    Map<String, String> params = new HashMap<>(paramsWithStats);
+    Warehouse wh = mock(Warehouse.class);
+
+    Table tbl1 = new TableBuilder()
+            .setDbName(DB_NAME)
+            .setTableName(TABLE_NAME)
+            .addCol("id", "int")
+            .setTableParams(params)
+            .build(null);
+    // Add Stats for create table 
+    HashMap<String, List<ByteBuffer>> dict = new HashMap<>();
+    ByteBuffer buffer = 
ByteBuffer.wrap("{\"enabled\":true,\"isIcebergTable\":true,\"columnNames\":[\"id\"]}".getBytes());
+    dict.put(StatsSetupConst.STATS_FOR_CREATE_TABLE, Arrays.asList(buffer));
+    tbl1.setDictionary(new ObjectDictionary(dict));
+
+    assertFalse(MetaStoreServerUtils.updateTableStatsForCreateTable(wh, db, 
tbl1, null,
+            MetastoreConf.newMetastoreConf(), new Path("/tmp/0"), false));
+  }
+
+  /**
+   * Verify that updateTableStatsForCreateTable() invokes calculation of table 
statistics when
+   * <ol>
+   *   <li>the table is not an Iceberg table</li>
+   * </ol>
+   */
+  @Test
+  public void testUpdateTableStatsForCreateTable_invokeStatsCalc() throws 
TException {

Review Comment:
   Done



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