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/08 13:39:30 UTC

[GitHub] [flink] twalthr opened a new pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

twalthr opened a new pull request #12857:
URL: https://github.com/apache/flink/pull/12857


   ## What is the purpose of the change
   
   Improves the validation logic for scalar/table function usage. It made catalog functions unresolvable before.
   
   ## Brief change log
   
   Remove checking for SQL function category.
   
   ## Verifying this change
   
   This change is already covered by existing tests, such as `FunctionITCase`.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   


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



[GitHub] [flink] flinkbot commented on pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12857:
URL: https://github.com/apache/flink/pull/12857#issuecomment-655528313


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit d52c63e8e43456629c23a571eefcb60bd26a11be (Wed Jul 08 13:42:29 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12857:
URL: https://github.com/apache/flink/pull/12857#issuecomment-655543169


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d52c63e8e43456629c23a571eefcb60bd26a11be",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4348",
       "triggerID" : "d52c63e8e43456629c23a571eefcb60bd26a11be",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d52c63e8e43456629c23a571eefcb60bd26a11be Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4348) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



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

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [flink] flinkbot edited a comment on pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12857:
URL: https://github.com/apache/flink/pull/12857#issuecomment-655543169


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d52c63e8e43456629c23a571eefcb60bd26a11be",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4348",
       "triggerID" : "d52c63e8e43456629c23a571eefcb60bd26a11be",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d52c63e8e43456629c23a571eefcb60bd26a11be Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4348) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] twalthr closed pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

Posted by GitBox <gi...@apache.org>.
twalthr closed pull request #12857:
URL: https://github.com/apache/flink/pull/12857


   


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



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

Posted by GitBox <gi...@apache.org>.
twalthr commented on pull request #12857:
URL: https://github.com/apache/flink/pull/12857#issuecomment-655988940


   Thanks @libenchao. Merging...


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



[GitHub] [flink] flinkbot commented on pull request #12857: [FLINK-18520][table] Fix unresolvable catalog table functions

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12857:
URL: https://github.com/apache/flink/pull/12857#issuecomment-655543169


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d52c63e8e43456629c23a571eefcb60bd26a11be",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "d52c63e8e43456629c23a571eefcb60bd26a11be",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d52c63e8e43456629c23a571eefcb60bd26a11be UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org