twalthr 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_r397249046
 
 

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/expressions/ApiExpressionUtils.java
 ##########
 @@ -198,4 +204,48 @@ public static boolean isFunction(Expression expression, 
BuiltInFunctionDefinitio
                }
                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 = 
callExpression.getFunctionDefinition();
+               if (functionDefinition instanceof BuiltInFunctionDefinition) {
+                       return 
FunctionIdentifier.of(((BuiltInFunctionDefinition) 
functionDefinition).getName());
 
 Review comment:
   should we merge this logic into `BuiltInFunctionDefinition`?

----------------------------------------------------------------
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

Reply via email to