use of org.apache.flink.table.catalog.stats.CatalogTableStatistics in project flink by apache.
the class CatalogStatisticsTest method createPartitionStats.
private void createPartitionStats(String part1, int part2, long rowCount) throws Exception {
ObjectPath path = ObjectPath.fromString("default_database.PartT");
LinkedHashMap<String, String> partSpecMap = new LinkedHashMap<>();
partSpecMap.put("part1", part1);
partSpecMap.put("part2", String.valueOf(part2));
CatalogPartitionSpec partSpec = new CatalogPartitionSpec(partSpecMap);
catalog.createPartition(path, partSpec, new CatalogPartitionImpl(new HashMap<>(), ""), true);
catalog.alterPartitionStatistics(path, partSpec, new CatalogTableStatistics(rowCount, 10, 1000L, 2000L), true);
}
use of org.apache.flink.table.catalog.stats.CatalogTableStatistics in project flink by apache.
the class CatalogStatisticsTest method alterTableStatisticsWithUnknownRowCount.
private void alterTableStatisticsWithUnknownRowCount(Catalog catalog, String tableName) throws TableNotExistException, TablePartitionedException {
catalog.alterTableStatistics(new ObjectPath(databaseName, tableName), new CatalogTableStatistics(CatalogTableStatistics.UNKNOWN.getRowCount(), 1, 10000, 200000), true);
catalog.alterTableColumnStatistics(new ObjectPath(databaseName, tableName), createColumnStats(), true);
}
use of org.apache.flink.table.catalog.stats.CatalogTableStatistics in project flink-mirror by flink-ci.
the class HiveCatalogHiveMetadataTest method checkStatistics.
private void checkStatistics(int inputStat, int expectStat) throws Exception {
catalog.dropTable(path1, true);
Map<String, String> properties = new HashMap<>();
properties.put(FactoryUtil.CONNECTOR.key(), SqlCreateHiveTable.IDENTIFIER);
properties.put(StatsSetupConst.ROW_COUNT, String.valueOf(inputStat));
properties.put(StatsSetupConst.NUM_FILES, String.valueOf(inputStat));
properties.put(StatsSetupConst.TOTAL_SIZE, String.valueOf(inputStat));
properties.put(StatsSetupConst.RAW_DATA_SIZE, String.valueOf(inputStat));
CatalogTable catalogTable = new CatalogTableImpl(TableSchema.builder().field("f0", DataTypes.INT()).build(), properties, "");
catalog.createTable(path1, catalogTable, false);
CatalogTableStatistics statistics = catalog.getTableStatistics(path1);
assertEquals(expectStat, statistics.getRowCount());
assertEquals(expectStat, statistics.getFileCount());
assertEquals(expectStat, statistics.getRawDataSize());
assertEquals(expectStat, statistics.getTotalSize());
}
use of org.apache.flink.table.catalog.stats.CatalogTableStatistics in project flink-mirror by flink-ci.
the class DatabaseCalciteSchema method extractTableStats.
private TableStats extractTableStats(ContextResolvedTable lookupResult, ObjectIdentifier identifier) {
if (lookupResult.isTemporary()) {
return TableStats.UNKNOWN;
}
final Catalog catalog = lookupResult.getCatalog().orElseThrow(IllegalStateException::new);
final ObjectPath tablePath = identifier.toObjectPath();
try {
final CatalogTableStatistics tableStatistics = catalog.getTableStatistics(tablePath);
final CatalogColumnStatistics columnStatistics = catalog.getTableColumnStatistics(tablePath);
return convertToTableStats(tableStatistics, columnStatistics);
} catch (TableNotExistException e) {
throw new ValidationException(format("Could not get statistic for table: [%s, %s, %s]", identifier.getCatalogName(), tablePath.getDatabaseName(), tablePath.getObjectName()), e);
}
}
use of org.apache.flink.table.catalog.stats.CatalogTableStatistics in project flink-mirror by flink-ci.
the class CatalogTest method testAlterTableStats.
@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);
// we don't check fileCount and totalSize here for hive will automatically calc and set to
// real num.
assertEquals(tableStats.getRowCount(), actual.getRowCount());
assertEquals(tableStats.getRawDataSize(), actual.getRawDataSize());
}
Aggregations