xuefuz commented on a change in pull request #9135: [FLINK-13296][table]
FunctionCatalog.lookupFunction() should check in memory functions if the target
function doesn't exist in catalog
URL: https://github.com/apache/flink/pull/9135#discussion_r304172711
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FunctionCatalog.java
##########
@@ -159,32 +159,31 @@ public void registerScalarFunction(String name,
ScalarFunction function) {
public Optional<FunctionLookup.Result> lookupFunction(String name) {
String functionName = normalizeName(name);
- FunctionDefinition userCandidate = null;
+ FunctionDefinition userCandidate;
Catalog catalog =
catalogManager.getCatalog(catalogManager.getCurrentCatalog()).get();
- ObjectPath functionPath = new
ObjectPath(catalogManager.getCurrentDatabase(), functionName);
- if (catalog.functionExists(functionPath)) {
+ try {
+ CatalogFunction catalogFunction = catalog.getFunction(
+ new
ObjectPath(catalogManager.getCurrentDatabase(), functionName));
+
if (catalog.getTableFactory().isPresent() &&
catalog.getTableFactory().get() instanceof
FunctionDefinitionFactory) {
- try {
- CatalogFunction catalogFunction =
catalog.getFunction(functionPath);
- FunctionDefinitionFactory factory =
(FunctionDefinitionFactory) catalog.getTableFactory().get();
+ FunctionDefinitionFactory factory =
(FunctionDefinitionFactory) catalog.getTableFactory().get();
- userCandidate =
factory.createFunctionDefinition(functionName, catalogFunction);
+ userCandidate =
factory.createFunctionDefinition(functionName, catalogFunction);
- return Optional.of(
- new FunctionLookup.Result(
-
ObjectIdentifier.of(catalogManager.getCurrentCatalog(),
catalogManager.getCurrentDatabase(), name),
- userCandidate)
- );
- } catch (FunctionNotExistException e) {
- // Ignore
- }
+ return Optional.of(
+ new FunctionLookup.Result(
+
ObjectIdentifier.of(catalogManager.getCurrentCatalog(),
catalogManager.getCurrentDatabase(), name),
+ userCandidate)
+ );
} else {
// TODO: should go thru function definition
discover service
}
+ } catch (FunctionNotExistException e) {
+ // Ignore
Review comment:
We can probably update the comment to be more meaningful.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services