libenchao commented on a change in pull request #12857:
URL: https://github.com/apache/flink/pull/12857#discussion_r451634594



##########
File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/catalog/FunctionCatalogOperatorTable.java
##########
@@ -208,11 +209,17 @@ private boolean verifyFunctionKind(
                // it would be nice to give a more meaningful exception when a 
scalar function is used instead
                // of a table function and vice versa, but we can do that only 
once FLIP-51 is implemented
 
-               if (definition.getKind() == FunctionKind.SCALAR &&
-                               (category == 
SqlFunctionCategory.USER_DEFINED_FUNCTION || category == 
SqlFunctionCategory.SYSTEM)) {
+               if (definition.getKind() == FunctionKind.SCALAR) {
+                       if (category != null && category.isTableFunction()) {
+                               throw new ValidationException(
+                                       String.format(
+                                               "Function '%s' cannot be used 
as a table function.",
+                                               identifier.asSummaryString()
+                                       )
+                               );
+                       }
                        return true;
-               } else if (definition.getKind() == FunctionKind.TABLE &&
-                               (category == 
SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION || category == 
SqlFunctionCategory.SYSTEM)) {
+               } else if (definition.getKind() == FunctionKind.TABLE) {

Review comment:
       How about we also check `category` should be table function for this 
branch?  
   I found that if we use a table function like "SELECT my_udtf(col) FROM T", 
the exception is a little wierd.




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


Reply via email to