bowenli86 commented on a change in pull request #8314: [FLINK-12365][table] Add stats related catalog APIs URL: https://github.com/apache/flink/pull/8314#discussion_r279500776
########## File path: flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogTest.java ########## @@ -1104,6 +1104,43 @@ public void testDropFunction_FunctionNotExist_ignored() throws Exception { catalog.dropDatabase(db1, false); } + // ------ statistics ------ + + @Test + public void testStatistics() throws Exception { + // Table related + catalog.createDatabase(db1, createDb(), false); + GenericCatalogTable table = createTable(); + catalog.createTable(path1, table, false); + assertTrue(catalog.getTableStatistics(path1) == null); + assertTrue(catalog.getTableColumnStatistics(path1) == null); + CatalogTableStatistics tableStatistics = new CatalogTableStatistics(5, 2, 100, 575); + catalog.alterTableStatistics(path1, tableStatistics, false); + CatalogTestUtil.checkEquals(tableStatistics, catalog.getTableStatistics(path1)); + CatalogColumnStatistics columnStatistics = new CatalogColumnStatistics(20L, 2L, 40.5, 17, 45, 15); + catalog.alterTableColumnStatistics(path1, columnStatistics, false); + CatalogTestUtil.checkEquals(columnStatistics, catalog.getTableColumnStatistics(path1)); + + // Partition related + catalog.createDatabase(db2, createDb(), false); + GenericCatalogTable table2 = createPartitionedTable(); + catalog.createTable(path2, table2, false); + CatalogPartitionSpec partitionSpec = createPartitionSpec(); + catalog.createPartition(path2, partitionSpec, createPartition(), false); + assertTrue(catalog.getPartitionStatistics(path2, partitionSpec) == null); + assertTrue(catalog.getPartitionColumnStatistics(path2, partitionSpec) == null); + catalog.alterPartitionStatistics(path2, partitionSpec, tableStatistics, false); + CatalogTestUtil.checkEquals(tableStatistics, catalog.getPartitionStatistics(path2, partitionSpec)); + catalog.alterPartitionColumnStatistics(path2, partitionSpec, columnStatistics, false); + CatalogTestUtil.checkEquals(columnStatistics, catalog.getPartitionColumnStatistics(path2, partitionSpec)); + + // Clean up Review comment: nit: we can remove these cleanups as they are already in close() ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services