[
https://issues.apache.org/jira/browse/FLINK-14782?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bowen Li closed FLINK-14782.
----------------------------
Resolution: Fixed
master: 71142816113a4f1d2160b73cdaed71c4bbfb575f
> 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
> Labels: pull-request-available
> Fix For: 1.10.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> 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)