use of org.apache.flink.table.catalog.exceptions.FunctionNotExistException in project flink by apache.
the class TableEnvironmentImpl method alterCatalogFunction.
private TableResultInternal alterCatalogFunction(AlterCatalogFunctionOperation alterCatalogFunctionOperation) {
String exMsg = getDDLOpExecuteErrorMsg(alterCatalogFunctionOperation.asSummaryString());
try {
CatalogFunction function = alterCatalogFunctionOperation.getCatalogFunction();
if (alterCatalogFunctionOperation.isTemporary()) {
throw new ValidationException("Alter temporary catalog function is not supported");
} else {
Catalog catalog = getCatalogOrThrowException(alterCatalogFunctionOperation.getFunctionIdentifier().getCatalogName());
catalog.alterFunction(alterCatalogFunctionOperation.getFunctionIdentifier().toObjectPath(), function, alterCatalogFunctionOperation.isIfExists());
}
return TableResultImpl.TABLE_RESULT_OK;
} catch (ValidationException e) {
throw e;
} catch (FunctionNotExistException e) {
throw new ValidationException(e.getMessage(), e);
} catch (Exception e) {
throw new TableException(exMsg, e);
}
}
use of org.apache.flink.table.catalog.exceptions.FunctionNotExistException in project flink by apache.
the class GenericInMemoryCatalog method alterFunction.
@Override
public void alterFunction(ObjectPath path, CatalogFunction newFunction, boolean ignoreIfNotExists) throws FunctionNotExistException {
checkNotNull(path);
checkNotNull(newFunction);
ObjectPath functionPath = normalize(path);
CatalogFunction existingFunction = functions.get(functionPath);
if (existingFunction != null) {
if (existingFunction.getClass() != newFunction.getClass()) {
throw new CatalogException(String.format("Function types don't match. Existing function is '%s' and new function is '%s'.", existingFunction.getClass().getName(), newFunction.getClass().getName()));
}
functions.put(functionPath, newFunction.copy());
} else if (!ignoreIfNotExists) {
throw new FunctionNotExistException(getName(), functionPath);
}
}
use of org.apache.flink.table.catalog.exceptions.FunctionNotExistException in project flink by apache.
the class HiveCatalog method alterFunction.
@Override
public void alterFunction(ObjectPath functionPath, CatalogFunction newFunction, boolean ignoreIfNotExists) throws FunctionNotExistException, CatalogException {
checkNotNull(functionPath, "functionPath cannot be null");
checkNotNull(newFunction, "newFunction cannot be null");
try {
// check if function exists
getFunction(functionPath);
Function hiveFunction;
if (newFunction instanceof CatalogFunctionImpl) {
hiveFunction = instantiateHiveFunction(functionPath, newFunction);
} else {
throw new CatalogException(String.format("Unsupported catalog function type %s", newFunction.getClass().getName()));
}
client.alterFunction(functionPath.getDatabaseName(), functionPath.getObjectName(), hiveFunction);
} catch (FunctionNotExistException e) {
if (!ignoreIfNotExists) {
throw e;
}
} catch (TException e) {
throw new CatalogException(String.format("Failed to alter function %s", functionPath.getFullName()), e);
}
}
use of org.apache.flink.table.catalog.exceptions.FunctionNotExistException in project flink by apache.
the class FunctionCatalog method resolvePreciseFunctionReference.
private Optional<ContextResolvedFunction> resolvePreciseFunctionReference(ObjectIdentifier oi) {
// resolve order:
// 1. Temporary functions
// 2. Catalog functions
ObjectIdentifier normalizedIdentifier = FunctionIdentifier.normalizeObjectIdentifier(oi);
CatalogFunction potentialResult = tempCatalogFunctions.get(normalizedIdentifier);
if (potentialResult != null) {
return Optional.of(ContextResolvedFunction.temporary(FunctionIdentifier.of(oi), getFunctionDefinition(oi.getObjectName(), potentialResult)));
}
Optional<Catalog> catalogOptional = catalogManager.getCatalog(oi.getCatalogName());
if (catalogOptional.isPresent()) {
Catalog catalog = catalogOptional.get();
try {
CatalogFunction catalogFunction = catalog.getFunction(new ObjectPath(oi.getDatabaseName(), oi.getObjectName()));
FunctionDefinition fd;
if (catalog.getFunctionDefinitionFactory().isPresent() && catalogFunction.getFunctionLanguage() != FunctionLanguage.PYTHON) {
fd = catalog.getFunctionDefinitionFactory().get().createFunctionDefinition(oi.getObjectName(), catalogFunction);
} else {
fd = getFunctionDefinition(oi.asSummaryString(), catalogFunction);
}
return Optional.of(ContextResolvedFunction.permanent(FunctionIdentifier.of(oi), fd));
} catch (FunctionNotExistException e) {
// Ignore
}
}
return Optional.empty();
}
use of org.apache.flink.table.catalog.exceptions.FunctionNotExistException in project flink by apache.
the class GenericInMemoryCatalog method dropFunction.
@Override
public void dropFunction(ObjectPath path, boolean ignoreIfNotExists) throws FunctionNotExistException {
checkNotNull(path);
ObjectPath functionPath = normalize(path);
if (functionExists(functionPath)) {
functions.remove(functionPath);
} else if (!ignoreIfNotExists) {
throw new FunctionNotExistException(getName(), functionPath);
}
}
Aggregations