dengzhhu653 commented on code in PR #5692:
URL: https://github.com/apache/hive/pull/5692#discussion_r2062818846


##########
standalone-metastore/metastore-tools/metastore-benchmarks/src/main/java/org/apache/hadoop/hive/metastore/tools/HMSBenchmarks.java:
##########
@@ -695,4 +697,68 @@ static DescriptiveStatistics 
benchmarkPartitionManagement(@NotNull MicroBenchmar
     }
   }
 
+  static DescriptiveStatistics benchmarkStatisticsManagement(@NotNull 
MicroBenchmark bench,
+                                                             @NotNull 
BenchData data,
+                                                             int tableCount) {
+
+    String dbName = data.dbName + "_" + tableCount;
+    String tableNamePrefix = data.tableName;
+    final HMSClient client = data.getClient();
+    final StatisticsManagementTask statsTask = new StatisticsManagementTask();
+    final FileSystem fs;
+    try {
+      fs = FileSystem.get(client.getHadoopConf());
+      client.getHadoopConf().set("hive.metastore.uris", 
client.getServerURI().toString());
+      
client.getHadoopConf().set("metastore.statistics.management.database.pattern", 
dbName);
+      statsTask.setConf(client.getHadoopConf());
+
+      client.createDatabase(dbName);
+      for (int i = 0; i < tableCount; i++) {
+        String tableName = tableNamePrefix + "_" + i;
+        Util.TableBuilder tableBuilder = new Util.TableBuilder(dbName, 
tableName)
+                .withType(TableType.MANAGED_TABLE)
+                .withColumns(createSchema(Arrays.asList("col1:string", 
"col2:int")))
+                
.withPartitionKeys(createSchema(Collections.singletonList("part_col")))
+                .withParameter("columnStatsAccurate", "true");
+
+        client.createTable(tableBuilder.build());
+        addManyPartitionsNoException(client, dbName, tableName, null, 
Collections.singletonList("part_col"), 100);
+
+        // simulate the partitions of each table which its stats has an old 
"lastAnalyzed"
+        List<Partition> partitions = client.listPartitions(dbName, tableName);
+        for (Partition partition : partitions) {
+          Map<String, String> params = partition.getParameters();
+          // to manually change the "lastAnalyzed" to an old time, ex. 400 days
+          params.put("lastAnalyzed", String.valueOf(System.currentTimeMillis() 
- TimeUnit.DAYS.toMillis(400)));

Review Comment:
   you need to set the lastAnalyzed of the column stats, not the partition 
parameters



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to