You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/09 07:45:11 UTC

[GitHub] [flink] twalthr commented on a change in pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

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



##########
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:
       Unfortunately, the category field is not very useful. That was also the cause for this bug. It seems that when you use a catalog function, this becomes just `USER_DEFINED_FUNCTION`. So we can't have a better exception right now.




----------------------------------------------------------------
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:
users@infra.apache.org