[
https://issues.apache.org/jira/browse/FLINK-14782?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bowen Li updated FLINK-14782:
-----------------------------
Summary: CoreModule#getFunctionDefinition should return empty optional when
function does not exist (was: CoreModule#getFunctionDefinition throws
exception when function does not exist)
> CoreModule#getFunctionDefinition should return empty optional when function
> does not exist
> ------------------------------------------------------------------------------------------
>
> Key: FLINK-14782
> URL: https://issues.apache.org/jira/browse/FLINK-14782
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 1.10.0
> Reporter: Dawid Wysakowicz
> Assignee: Bowen Li
> Priority: Major
> Fix For: 1.10.0
>
>
> As in the subject CoreModule#getFunctionDefinition throws exception when
> function does not exist, while it should just return an Optional.empty().
> {code}
> @Test
> public void testGetFunction() {
> Optional<FunctionDefinition> optional =
> CoreModule.INSTANCE.getFunctionDefinition("AAA");
> }
> {code}
> An easy fix would be to change the {{CoreModule#getFunctionDefinition}} to
> {code}
> @Override
> public Optional<FunctionDefinition> getFunctionDefinition(String name) {
> return BuiltInFunctionDefinitions.getDefinitions().stream()
> .filter(f -> f.getName().equalsIgnoreCase(name))
> .findFirst()
> .map(Function.identity());
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)