dengzhhu653 commented on code in PR #5578:
URL: https://github.com/apache/hive/pull/5578#discussion_r1918067977
##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java:
##########
@@ -1856,6 +1859,49 @@ public void testColumnStatistics() throws Throwable {
colStats2 = client.getTableColumnStatistics(
dbName, tblName, Lists.newArrayList(colName[0]), ENGINE).get(0);
+ // test delete column stats; if no col name is passed all column stats
associated with the
+ // table is deleted
+ status = client.deleteTableColumnStatistics(dbName, tblName, colName[0],
ENGINE);
+ assertTrue(status);
+ // try to query stats for a column for which stats doesn't exist
+ stats = client.getTableColumnStatistics(
+ dbName, tblName, Lists.newArrayList(colName[0]), ENGINE);
+ assertTrue("stats are not empty: " + stats, stats.isEmpty());
+
+ // reset the column stats
+ client.updateTableColumnStatistics(colStats);
+ // test delete multiple column stats(column names can be null, or one,
or multiple)
+ // case 1: column names are null, all column stats should be deleted
+ status = client.deleteTableMultiColumnStatistics(dbName, tblName, null,
ENGINE);
+ assertTrue(status);
+ stats = client.getTableColumnStatistics(
+ dbName, tblName, Lists.newArrayList(colName[0]), ENGINE);
+ assertTrue("stats are not empty: " + stats, stats.isEmpty());
+ stats = client.getTableColumnStatistics(
+ dbName, tblName, Lists.newArrayList(colName[1]), ENGINE);
+ assertTrue("stats are not empty: " + stats, stats.isEmpty());
+
+ client.updateTableColumnStatistics(colStats);
+ // case 2: column names only contains one column name, then that column
stats should be deleted
+ List<String> singleColNameList = new ArrayList<>();
+ singleColNameList.add(colName[0]);
+ status = client.deleteTableMultiColumnStatistics(dbName, tblName,
singleColNameList, ENGINE);
+ assertTrue(status);
+ stats = client.getTableColumnStatistics(
+ dbName, tblName, Lists.newArrayList(colName[0]), ENGINE);
+ assertTrue("stats are not empty: " + stats, stats.isEmpty());
+
+ client.updateTableColumnStatistics(colStats);
+ //case 3: column names contains multiple column names, then delete the
column stats in the column name list
+ status = client.deleteTableMultiColumnStatistics(dbName, tblName,
Arrays.asList(colName), ENGINE);
+ assertTrue(status);
+ stats = client.getTableColumnStatistics(
Review Comment:
get the stats in a round, `client.getTableColumnStatistics(dbName, tblName,
Lists.newArrayList(colName), ENGINE);`
--
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]