dawidwys commented on a change in pull request #11280: [FLINK-16377][table] 
Support inline user defined functions in expression dsl
URL: https://github.com/apache/flink/pull/11280#discussion_r397676230

 File path: 
 @@ -198,4 +204,48 @@ public static boolean isFunction(Expression expression, 
                return false;
+       /**
+        * Extracts a {@link FunctionIdentifier} for the given {@link 
CallExpression}. If the call is an inline funcion
+        * ({@link CallExpression#getFunctionIdentifier()} returns empty)
+        * <ul>
+        *     <li>it uses {@link BuiltInFunctionDefinition#getName()} ()} for 
built in functions</li>
+        *     <li>it uses {@link UserDefinedFunction#functionIdentifier()} for 
user defined functions</li>
+        *     <li>it uses {@link FunctionDefinition#toString()} ()} for any 
other functions</li>
+        * </ul>
+        */
+       public static FunctionIdentifier getFunctionIdentifier(CallExpression 
callExpression) {
+               if (callExpression.getFunctionIdentifier().isPresent()) {
+                       return callExpression.getFunctionIdentifier().get();
+               } else {
+                       return getInlineFunctionIdentifier(callExpression);
+               }
+       }
+       private static FunctionIdentifier 
getInlineFunctionIdentifier(CallExpression callExpression) {
+               FunctionDefinition functionDefinition = 
+               if (functionDefinition instanceof BuiltInFunctionDefinition) {
+                       return 
 Review comment:
   Not sure, theoretically `BuiltInFunctionDefinition` can also be registered 
in an arbitrary path. Then having a `FunctionIdentifier` in the function 
definition would be wrong. `FunctionDefinition` is not aware of the path it 
comes from. It can even be registered at multiple locations.
   As far as I understand the difference between built-in and user defined 
functions is where the implementation comes from. For user defined functions 
the implementation comes from the definition whereas for bult-in it is looked 
up in the planner.

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:

With regards,
Apache Git Services

Reply via email to