@Test
  public void testUpdatePartitionStat_doesNotUpdateStats() throws Exception {
    final String DB_NAME = "db1";
    final String TABLE_NAME = "tbl1";
    Table tbl = new TableBuilder()
        .setDbName(DB_NAME)
        .setTableName(TABLE_NAME)
        .addCol("id", "int")
        .addTableParam(StatsSetupConst.DO_NOT_UPDATE_STATS, "true")
        .build(null);
    List<String> vals = new ArrayList<>(2);
    vals.add("col1");
    vals.add("col2");
    Partition part = new Partition();
    part.setDbName(DB_NAME);
    part.setTableName(TABLE_NAME);
    part.setValues(vals);
    part.setParameters(new HashMap<>());
    part.setSd(tbl.getSd().deepCopy());
    part.getSd().setSerdeInfo(tbl.getSd().getSerdeInfo());
    part.getSd().setLocation(tbl.getSd().getLocation() + "/partCol=1");
    Warehouse wh = mock(Warehouse.class);
    //Execute initializeAddedPartition() and it should not trigger updatePartitionStatsFast() as DO_NOT_UPDATE_STATS is true
    HMSHandler hms = new HMSHandler("", conf);
    Method m = hms.getClass().getDeclaredMethod("initializeAddedPartition", Table.class, Partition.class,
            boolean.class, EnvironmentContext.class);
    m.setAccessible(true);
    //Invoke initializeAddedPartition();
    m.invoke(hms, tbl, part, false, null);
    verify(wh, never()).getFileStatusesForLocation(part.getSd().getLocation());

    //Remove tbl's DO_NOT_UPDATE_STATS & set STATS_AUTO_GATHER = false
    tbl.unsetParameters();
    MetastoreConf.setBoolVar(conf, ConfVars.STATS_AUTO_GATHER, false);
    m.invoke(hms, tbl, part, false, null);
    verify(wh, never()).getFileStatusesForLocation(part.getSd().getLocation());

    //Set STATS_AUTO_GATHER = true and set tbl as a VIRTUAL_VIEW
    MetastoreConf.setBoolVar(conf, ConfVars.STATS_AUTO_GATHER, true);
    tbl.setTableType("VIRTUAL_VIEW");
    m.invoke(hms, tbl, part, false, null);
    verify(wh, never()).getFileStatusesForLocation(part.getSd().getLocation());
  }
While altering partition(s), verify DO NOT calculate partition statistics if
<ol>
  <li>table property DO_NOT_UPDATE_STATS is true</li>
  <li>STATS_AUTO_GATHER is false</li>
  <li>Is View</li>
</ol>
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java