use of org.apache.flink.table.catalog.exceptions.CatalogException in project flink by apache.
the class TableEnvironmentImpl method createCatalog.
private TableResultInternal createCatalog(CreateCatalogOperation operation) {
String exMsg = getDDLOpExecuteErrorMsg(operation.asSummaryString());
try {
String catalogName = operation.getCatalogName();
Map<String, String> properties = operation.getProperties();
Catalog catalog = FactoryUtil.createCatalog(catalogName, properties, tableConfig.getConfiguration(), userClassLoader);
catalogManager.registerCatalog(catalogName, catalog);
return TableResultImpl.TABLE_RESULT_OK;
} catch (CatalogException e) {
throw new ValidationException(exMsg, e);
}
}
use of org.apache.flink.table.catalog.exceptions.CatalogException in project flink by apache.
the class CatalogManager method unregisterCatalog.
/**
* Unregisters a catalog under the given name. The catalog name must be existed.
*
* @param catalogName name under which to unregister the given catalog.
* @param ignoreIfNotExists If false exception will be thrown if the table or database or
* catalog to be altered does not exist.
* @throws CatalogException if the unregistration of the catalog under the given name failed
*/
public void unregisterCatalog(String catalogName, boolean ignoreIfNotExists) {
checkArgument(!StringUtils.isNullOrWhitespaceOnly(catalogName), "Catalog name cannot be null or empty.");
if (catalogs.containsKey(catalogName)) {
Catalog catalog = catalogs.remove(catalogName);
catalog.close();
} else if (!ignoreIfNotExists) {
throw new CatalogException(format("Catalog %s does not exist.", catalogName));
}
}
use of org.apache.flink.table.catalog.exceptions.CatalogException 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