bowenli86 commented on a change in pull request #8636: 
[FLINK-12237][hive]Support Hive table stats related operations in HiveCatalog
URL: https://github.com/apache/flink/pull/8636#discussion_r293935284
 
 

 ##########
 File path: 
flink-table/flink-table-common/src/test/java/org/apache/flink/table/catalog/CatalogTestBase.java
 ##########
 @@ -1082,6 +1083,64 @@ public void testListPartitionPartialSpec() throws 
Exception {
                assertEquals(1, catalog.listPartitions(path1, 
createAnotherPartitionSpecSubset()).size());
        }
 
+
+       // ------ table and column stats ------
+
+       @Test
+       public void testGetTableStats_TableNotExistException() throws Exception{
+               catalog.createDatabase(db1, createDb(), false);
+               
exception.expect(org.apache.flink.table.api.TableNotExistException.class);
+               catalog.getTableStatistics(path1);
+       }
+
+       @Test
+       public void testGetPartitionStats() throws Exception{
+               catalog.createDatabase(db1, createDb(), false);
+               catalog.createTable(path1, createPartitionedTable(), false);
+               catalog.createPartition(path1, createPartitionSpec(), 
createPartition(), false);
+               // there're essentially no stats, so nothing to assert
+               catalog.getPartitionStatistics(path1, createPartitionSpec());
+       }
+
+       @Test
+       public void testAlterTableStats() throws Exception{
+               // Non-partitioned table
+               catalog.createDatabase(db1, createDb(), false);
+               CatalogTable table = createTable();
+               catalog.createTable(path1, table, false);
+               CatalogTableStatistics tableStats = new 
CatalogTableStatistics(100, 10, 1000, 10000);
+               catalog.alterTableStatistics(path1, tableStats, false);
+               CatalogTableStatistics actual = 
catalog.getTableStatistics(path1);
+
+               assertEquals(tableStats.toString(), actual.toString());
+       }
+
+       @Test
+       public void testAlterTableStats_partitionedTable() throws Exception {
+               // alterTableStats() should do nothing for partitioned tables
+               // getTableStats() should return empty column stats for 
partitioned tables
+               catalog.createDatabase(db1, createDb(), false);
+               catalog.createTable(path1, createPartitionedTable(), false);
+
+               CatalogTableStatistics stats = new CatalogTableStatistics(100, 
1, 1000, 10000);
+
 
 Review comment:
   > // alterTableStats() should do nothing for partitioned tables
                // getTableStats() should return empty column stats for 
partitioned tables
   
   as the comment describes, we should also assert 
`assertEquals(CatalogTableStatistics.UNKNOWN, 
catalog.getTableStatistics(path1));` before the altering

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to