use of org.apache.flink.table.catalog.exceptions.TableNotExistException in project flink by apache.
the class GenericInMemoryCatalog method getTableColumnStatistics.
@Override
public CatalogColumnStatistics getTableColumnStatistics(ObjectPath tablePath) throws TableNotExistException {
checkNotNull(tablePath);
if (!tableExists(tablePath)) {
throw new TableNotExistException(getName(), tablePath);
}
CatalogColumnStatistics result = tableColumnStats.get(tablePath);
return result != null ? result.copy() : CatalogColumnStatistics.UNKNOWN;
}
use of org.apache.flink.table.catalog.exceptions.TableNotExistException in project flink by apache.
the class GenericInMemoryCatalog method alterTableStatistics.
@Override
public void alterTableStatistics(ObjectPath tablePath, CatalogTableStatistics tableStatistics, boolean ignoreIfNotExists) throws TableNotExistException {
checkNotNull(tablePath);
checkNotNull(tableStatistics);
if (tableExists(tablePath)) {
tableStats.put(tablePath, tableStatistics.copy());
} else if (!ignoreIfNotExists) {
throw new TableNotExistException(getName(), tablePath);
}
}
use of org.apache.flink.table.catalog.exceptions.TableNotExistException in project flink by apache.
the class GenericInMemoryCatalog method dropTable.
// ------ tables and views ------
@Override
public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists) throws TableNotExistException {
checkNotNull(tablePath);
if (tableExists(tablePath)) {
tables.remove(tablePath);
tableStats.remove(tablePath);
tableColumnStats.remove(tablePath);
partitions.remove(tablePath);
partitionStats.remove(tablePath);
partitionColumnStats.remove(tablePath);
} else if (!ignoreIfNotExists) {
throw new TableNotExistException(getName(), tablePath);
}
}
use of org.apache.flink.table.catalog.exceptions.TableNotExistException in project flink by apache.
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.exceptions.TableNotExistException in project flink by apache.
the class TestValuesCatalog method listPartitionsByFilter.
@Override
public List<CatalogPartitionSpec> listPartitionsByFilter(ObjectPath tablePath, List<Expression> filters) throws TableNotExistException, TableNotPartitionedException, CatalogException {
if (!supportListPartitionByFilter) {
throw new UnsupportedOperationException("TestValuesCatalog doesn't support list partition by filters");
}
List<CatalogPartitionSpec> partitions = listPartitions(tablePath);
if (partitions.isEmpty()) {
return partitions;
}
CatalogBaseTable table = this.getTable(tablePath);
TableSchema schema = table.getSchema();
List<ResolvedExpression> resolvedExpressions = filters.stream().map(filter -> {
if (filter instanceof ResolvedExpression) {
return (ResolvedExpression) filter;
}
throw new UnsupportedOperationException(String.format("TestValuesCatalog only works with resolved expressions. Get unresolved expression: %s", filter));
}).collect(Collectors.toList());
return partitions.stream().filter(partition -> {
Function<String, Comparable<?>> getter = getValueGetter(partition.getPartitionSpec(), schema);
return FilterUtils.isRetainedAfterApplyingFilterPredicates(resolvedExpressions, getter);
}).collect(Collectors.toList());
}
Aggregations