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 2021/03/18 12:04:41 UTC

[GitHub] [flink] fsk119 opened a new pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

fsk119 opened a new pull request #15265:
URL: https://github.com/apache/flink/pull/15265


   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *This PR is the first step to unify the SQL Client parser and SQL parser. We add a `ParseStrategyParser` that responsible to convert the input command to `Operation`.*
   
   *We also move the `getCompletionHints` from the `Planner` to `Paser`. Because `Parser` has the knowledge about the relationship between the statement and operation.*
   
   
   ## Brief change log
   
     - *Add the command operations, e.g. `HelpOperation`.*
     - *Add `StatementParseStrategy` and to parse statement to `Operation`*
     - *`ParserImpl` will first use `ParseStrategyParser` to parse operation and then use `CalciteParser` to parse.*
   
   
   ## Verifying this change
   
   Most tests are in the `PaserImplTest` including parsing commands and get completion hints.
   
   For hive compatibility, add some test to parse commands.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / **not documented**)
   


----------------------------------------------------------------
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 #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     }, {
       "hash" : "afd793076a5c702aabc57198919019985529970e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "afd793076a5c702aabc57198919019985529970e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 24478272be8cc8034c79f3296fa286b22b856f52 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353) 
   * afd793076a5c702aabc57198919019985529970e 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] fsk119 commented on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   I think we can rebase this PR until all concerns are resolved.


-- 
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 #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     }, {
       "hash" : "afd793076a5c702aabc57198919019985529970e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392",
       "triggerID" : "afd793076a5c702aabc57198919019985529970e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 24478272be8cc8034c79f3296fa286b22b856f52 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353) 
   * afd793076a5c702aabc57198919019985529970e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392) 
   
   <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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d6784d65ea57a6bccf4bbcb12186993e78056be Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342) 
   * 24478272be8cc8034c79f3296fa286b22b856f52 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353) 
   
   <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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d6784d65ea57a6bccf4bbcb12186993e78056be Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342) 
   
   <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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 99c9499a5a4b7f2850fbc0d7ae33f896125a58db Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969) 
   * 5d6784d65ea57a6bccf4bbcb12186993e78056be 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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     }, {
       "hash" : "afd793076a5c702aabc57198919019985529970e",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392",
       "triggerID" : "afd793076a5c702aabc57198919019985529970e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * afd793076a5c702aabc57198919019985529970e Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392) 
   
   <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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     }, {
       "hash" : "afd793076a5c702aabc57198919019985529970e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392",
       "triggerID" : "afd793076a5c702aabc57198919019985529970e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f37d8d4d90b8ba9c8df2209574ea5dcd47571057",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15430",
       "triggerID" : "f37d8d4d90b8ba9c8df2209574ea5dcd47571057",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f37d8d4d90b8ba9c8df2209574ea5dcd47571057 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15430) 
   
   <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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     }, {
       "hash" : "afd793076a5c702aabc57198919019985529970e",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392",
       "triggerID" : "afd793076a5c702aabc57198919019985529970e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f37d8d4d90b8ba9c8df2209574ea5dcd47571057",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "f37d8d4d90b8ba9c8df2209574ea5dcd47571057",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * afd793076a5c702aabc57198919019985529970e Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392) 
   * f37d8d4d90b8ba9c8df2209574ea5dcd47571057 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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     }, {
       "hash" : "afd793076a5c702aabc57198919019985529970e",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392",
       "triggerID" : "afd793076a5c702aabc57198919019985529970e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "f37d8d4d90b8ba9c8df2209574ea5dcd47571057",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15430",
       "triggerID" : "f37d8d4d90b8ba9c8df2209574ea5dcd47571057",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * afd793076a5c702aabc57198919019985529970e Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15392) 
   * f37d8d4d90b8ba9c8df2209574ea5dcd47571057 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15430) 
   
   <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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 99c9499a5a4b7f2850fbc0d7ae33f896125a58db Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969) 
   
   <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] wuchong commented on a change in pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15265:
URL: https://github.com/apache/flink/pull/15265#discussion_r601068115



##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.fail;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    private List<TestSpec> testLegalStatements;
+    private List<TestSpec> testIllegalStatements;
+
+    @Before
+    public void setup() {
+        testLegalStatements =
+                Arrays.asList(
+                        TestSpec.forStatement("ClEaR").expectedSummary("CLEAR"),
+                        TestSpec.forStatement("hElP").expectedSummary("HELP"),
+                        TestSpec.forStatement("qUIT").expectedSummary("QUIT"),
+                        TestSpec.forStatement("ExIT").expectedSummary("EXIT"),
+                        TestSpec.forStatement("REsEt").expectedSummary("RESET"),
+                        TestSpec.forStatement("   SEt ").expectedSummary("SET"),
+                        TestSpec.forStatement("SET execution.runtime-type=batch")
+                                .expectedSummary("SET execution.runtime-type=batch"),
+                        TestSpec.forStatement("SET pipeline.jars = /path/to/test-_-jar.jar")
+                                .expectedSummary("SET pipeline.jars=/path/to/test-_-jar.jar"),
+                        TestSpec.forStatement("USE test.db1").expectedSummary("USE test.db1"),
+                        TestSpec.forStatement("SHOW tables").expectedSummary("SHOW TABLES"));
+
+        testIllegalStatements =
+                Arrays.asList(
+                        TestSpec.forStatement("SET pipeline.name = ' '"),

Review comment:
       If it's not easy to support this, we can create an issue to track this, and add a TODO comment above this. 




-- 
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] wuchong commented on a change in pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15265:
URL: https://github.com/apache/flink/pull/15265#discussion_r600144592



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/parse/ParseStrategyParser.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.parse;
+
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.operations.Operation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** Parser that uses {@link StatementParseStrategy} to parse statement to {@link Operation}. */
+public class ParseStrategyParser {

Review comment:
       What do you think about renaming it to `ExtendedParser` and also move `CalciteParser` into the same package ? 
   
   
   ```suggestion
   /** {@link ExtendedParser} is used for parsing some special command which can't supported by {@link CalciteParser}, e.g. {@code SET key=value} contains special characters in key and value identifier. It's also good to move some parsring here to avoid introducing new reserved keywords.  */
   public class ParseStrategyParser {
   ```

##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.SqlParserException;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.command.ClearOperation;
+import org.apache.flink.table.operations.command.HelpOperation;
+import org.apache.flink.table.operations.command.QuitOperation;
+import org.apache.flink.table.operations.command.ResetOperation;
+import org.apache.flink.table.operations.command.SetOperation;
+import org.apache.flink.table.operations.command.SourceOperation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.hamcrest.Matcher;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    @Test
+    public void testClearCommand() {
+        assertSimpleCommand("ClEaR", instanceOf(ClearOperation.class));
+    }
+
+    @Test
+    public void testHelpCommand() {
+        assertSimpleCommand("hELp", instanceOf(HelpOperation.class));
+    }
+
+    @Test
+    public void testQuitCommand() {
+        assertSimpleCommand("qUIt", instanceOf(QuitOperation.class));
+        assertSimpleCommand("Exit", instanceOf(QuitOperation.class));
+    }
+
+    @Test
+    public void testResetCommand() {
+        assertSimpleCommand("REsEt", instanceOf(ResetOperation.class));
+    }
+
+    @Test
+    public void testSetOperation() {
+        assertSetCommand("   SEt       ");
+        assertSetCommand("SET execution.runtime-type= batch", "execution.runtime-type", "batch");
+        assertSetCommand(
+                "SET pipeline.jars = /path/to/test-_-jar.jar",
+                "pipeline.jars",
+                "/path/to/test-_-jar.jar");

Review comment:
       Add a test `SET pipeline.name = ' '`

##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/command/SourceOperation.java
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.operations.command;
+
+import org.apache.flink.table.operations.Operation;
+
+/** Operation that represent SOURCE command. */
+public class SourceOperation implements Operation {

Review comment:
       Can we remove the SOURCE command? It seem there is no tests for this command and we have never documented it and no user used it. 

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/parse/ParseStrategyParser.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.parse;
+
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.operations.Operation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** Parser that uses {@link StatementParseStrategy} to parse statement to {@link Operation}. */
+public class ParseStrategyParser {
+
+    public static final ParseStrategyParser INSTANCE = new ParseStrategyParser();
+
+    private static final List<StatementParseStrategy> REGEX_STRATEGIES =

Review comment:
       `REGEX_STRATEGIES` ==> `PARSE_STRATEGIES` 
   
   
   

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/parse/StatementParseStrategy.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.parse;
+
+import org.apache.flink.table.operations.Operation;
+
+import java.util.regex.Pattern;
+
+/** Strategy to parse statement to {@link Operation}. */
+public abstract class StatementParseStrategy {

Review comment:
       1. What do you think about renaming to `ExtendedParseStrategy` ?
   2. The implementation already be coupled to regex, would be better to split it into interface and a regex-based abstract class `AbstractRegexParseStrategy`. 

##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.SqlParserException;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.command.ClearOperation;
+import org.apache.flink.table.operations.command.HelpOperation;
+import org.apache.flink.table.operations.command.QuitOperation;
+import org.apache.flink.table.operations.command.ResetOperation;
+import org.apache.flink.table.operations.command.SetOperation;
+import org.apache.flink.table.operations.command.SourceOperation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.hamcrest.Matcher;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    @Test
+    public void testClearCommand() {
+        assertSimpleCommand("ClEaR", instanceOf(ClearOperation.class));
+    }
+
+    @Test
+    public void testHelpCommand() {
+        assertSimpleCommand("hELp", instanceOf(HelpOperation.class));
+    }
+
+    @Test
+    public void testQuitCommand() {
+        assertSimpleCommand("qUIt", instanceOf(QuitOperation.class));
+        assertSimpleCommand("Exit", instanceOf(QuitOperation.class));

Review comment:
       Would be better to refactor the tests into `Parameterized` `TestSpec`, see: `org.apache.flink.table.types.DataTypesTest`. The `TestSpec` can simply compare the parsed Operation with expected Operation using `asSummaryString`. 
   
   That would be easier to add new command parse in the future.

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/delegation/ParserImpl.java
##########
@@ -70,6 +76,12 @@ public ParserImpl(
     public List<Operation> parse(String statement) {
         CalciteParser parser = calciteParserSupplier.get();
         FlinkPlannerImpl planner = validatorSupplier.get();
+
+        // use ParseStrategyParser to parse command first
+        if (ParseStrategyParser.INSTANCE.matches(statement)) {
+            return Collections.singletonList(ParseStrategyParser.INSTANCE.convert(statement));

Review comment:
       I think `ParseStrategyParser` doesn't need to expose two methods, otherwise, it will need to pattern match twice. The `ParseStrategyParser` can expose just one method:
   
   
   ```java
       public Optional<Operation> parse(String statement) {
           for (ExtendedParserStrategy strategy : REGEX_STRATEGIES) {
               if (strategy.match(statement)) {
                   return Optional.of(strategy.convert(statement));
               }
           }
           return Optional.empty();
       }
   ```
   
   
   
   
    

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/delegation/ParserImpl.java
##########
@@ -101,6 +113,29 @@ public ResolvedExpression parseSqlExpression(String sqlExpression, TableSchema i
                 sqlExpressionExpanded);
     }
 
+    public String[] getCompletionHints(String statement, int cursor) {
+        List<String> candidates =
+                new ArrayList<>(
+                        Arrays.asList(
+                                ParseStrategyParser.INSTANCE.getCompletionHints(

Review comment:
       Could you add a final member variable `extendedParser` instead of referencing `ParseStrategyParser.INSTANCE` so many times?

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/delegation/ParserImpl.java
##########
@@ -101,6 +113,29 @@ public ResolvedExpression parseSqlExpression(String sqlExpression, TableSchema i
                 sqlExpressionExpanded);
     }
 
+    public String[] getCompletionHints(String statement, int cursor) {
+        List<String> candidates =
+                new ArrayList<>(
+                        Arrays.asList(
+                                ParseStrategyParser.INSTANCE.getCompletionHints(
+                                        statement, cursor)));
+
+        // fall back to sql advisor

Review comment:
       this is not fallback, please correct the comment.

##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/delegation/ParserImpl.java
##########
@@ -70,6 +76,12 @@ public ParserImpl(
     public List<Operation> parse(String statement) {
         CalciteParser parser = calciteParserSupplier.get();
         FlinkPlannerImpl planner = validatorSupplier.get();
+
+        // use ParseStrategyParser to parse command first
+        if (ParseStrategyParser.INSTANCE.matches(statement)) {

Review comment:
       move to the beginning of this method. 

##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.SqlParserException;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.command.ClearOperation;
+import org.apache.flink.table.operations.command.HelpOperation;
+import org.apache.flink.table.operations.command.QuitOperation;
+import org.apache.flink.table.operations.command.ResetOperation;
+import org.apache.flink.table.operations.command.SetOperation;
+import org.apache.flink.table.operations.command.SourceOperation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.hamcrest.Matcher;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    @Test
+    public void testClearCommand() {
+        assertSimpleCommand("ClEaR", instanceOf(ClearOperation.class));
+    }
+
+    @Test
+    public void testHelpCommand() {
+        assertSimpleCommand("hELp", instanceOf(HelpOperation.class));
+    }
+
+    @Test
+    public void testQuitCommand() {
+        assertSimpleCommand("qUIt", instanceOf(QuitOperation.class));
+        assertSimpleCommand("Exit", instanceOf(QuitOperation.class));
+    }
+
+    @Test
+    public void testResetCommand() {
+        assertSimpleCommand("REsEt", instanceOf(ResetOperation.class));
+    }
+
+    @Test
+    public void testSetOperation() {
+        assertSetCommand("   SEt       ");
+        assertSetCommand("SET execution.runtime-type= batch", "execution.runtime-type", "batch");
+        assertSetCommand(
+                "SET pipeline.jars = /path/to/test-_-jar.jar",
+                "pipeline.jars",
+                "/path/to/test-_-jar.jar");
+
+        assertFailedSetCommand("SET execution.runtime-type=");
+    }
+
+    @Test
+    public void testGetCompletionHints() {
+        String[] hints = parser.getCompletionHints("SE", 2);
+        System.out.println(hints[0]);

Review comment:
       assert instead of print. 

##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.SqlParserException;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.operations.command.ClearOperation;
+import org.apache.flink.table.operations.command.HelpOperation;
+import org.apache.flink.table.operations.command.QuitOperation;
+import org.apache.flink.table.operations.command.ResetOperation;
+import org.apache.flink.table.operations.command.SetOperation;
+import org.apache.flink.table.operations.command.SourceOperation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.hamcrest.Matcher;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    @Test
+    public void testClearCommand() {
+        assertSimpleCommand("ClEaR", instanceOf(ClearOperation.class));
+    }
+
+    @Test
+    public void testHelpCommand() {
+        assertSimpleCommand("hELp", instanceOf(HelpOperation.class));
+    }
+
+    @Test
+    public void testQuitCommand() {
+        assertSimpleCommand("qUIt", instanceOf(QuitOperation.class));
+        assertSimpleCommand("Exit", instanceOf(QuitOperation.class));

Review comment:
       Besides, please also add tests for statemenets parsed by Calcite. 




-- 
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 #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   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 99c9499a5a4b7f2850fbc0d7ae33f896125a58db (Thu Mar 18 12:06:56 UTC 2021)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-21836).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <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] wuchong commented on a change in pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15265:
URL: https://github.com/apache/flink/pull/15265#discussion_r601036827



##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.fail;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    private List<TestSpec> testLegalStatements;
+    private List<TestSpec> testIllegalStatements;
+
+    @Before
+    public void setup() {
+        testLegalStatements =
+                Arrays.asList(
+                        TestSpec.forStatement("ClEaR").expectedSummary("CLEAR"),
+                        TestSpec.forStatement("hElP").expectedSummary("HELP"),
+                        TestSpec.forStatement("qUIT").expectedSummary("QUIT"),
+                        TestSpec.forStatement("ExIT").expectedSummary("EXIT"),
+                        TestSpec.forStatement("REsEt").expectedSummary("RESET"),
+                        TestSpec.forStatement("   SEt ").expectedSummary("SET"),
+                        TestSpec.forStatement("SET execution.runtime-type=batch")
+                                .expectedSummary("SET execution.runtime-type=batch"),
+                        TestSpec.forStatement("SET pipeline.jars = /path/to/test-_-jar.jar")
+                                .expectedSummary("SET pipeline.jars=/path/to/test-_-jar.jar"),
+                        TestSpec.forStatement("USE test.db1").expectedSummary("USE test.db1"),
+                        TestSpec.forStatement("SHOW tables").expectedSummary("SHOW TABLES"));
+
+        testIllegalStatements =
+                Arrays.asList(
+                        TestSpec.forStatement("SET pipeline.name = ' '"),
+                        TestSpec.forStatement("SET execution.runtime-type="));
+    }
+
+    @Test
+    public void testParseLegalStatements() {
+        for (TestSpec spec : testLegalStatements) {
+            Operation op = parser.parse(spec.statement).get(0);
+            Assert.assertEquals(op.asSummaryString(), op.asSummaryString());
+        }
+    }
+
+    @Test
+    public void testParseIllegalStatements() {
+        for (TestSpec spec : testIllegalStatements) {
+            testIllegalTestSpec(spec);
+        }
+    }
+
+    @Test
+    public void testCompletionTest() {
+        verifySqlCompletion("QU", 1, new String[] {"QUIT"});
+        verifySqlCompletion("SE", 1, new String[] {"SET"});
+        verifySqlCompletion("", 0, new String[] {"CLEAR", "HELP", "EXIT", "QUIT", "RESET", "SET"});
+
+        verifySqlCompletion("SELECT a fram b", 10, new String[] {"FETCH", "FROM"});
+    }
+
+    // ~ Tool Methods ----------------------------------------------------------
+
+    private static class TestSpec {
+
+        private String statement;
+        private String expectedSummary;
+
+        private TestSpec(String statement) {
+            this.statement = statement;
+        }
+
+        static TestSpec forStatement(String statement) {
+            return new TestSpec(statement);
+        }
+
+        TestSpec expectedSummary(String expectedSummary) {
+            this.expectedSummary = expectedSummary;
+            return this;
+        }
+    }
+
+    private void testIllegalTestSpec(TestSpec spec) {

Review comment:
       nit: we don't need to extract this method. 

##########
File path: flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/delegation/ParserImplTest.java
##########
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.delegation;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.catalog.CatalogManager;
+import org.apache.flink.table.catalog.FunctionCatalog;
+import org.apache.flink.table.catalog.GenericInMemoryCatalog;
+import org.apache.flink.table.delegation.Parser;
+import org.apache.flink.table.module.ModuleManager;
+import org.apache.flink.table.operations.Operation;
+import org.apache.flink.table.planner.calcite.FlinkPlannerImpl;
+import org.apache.flink.table.planner.catalog.CatalogManagerCalciteSchema;
+import org.apache.flink.table.utils.CatalogManagerMocks;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.calcite.jdbc.CalciteSchemaBuilder.asRootSchema;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.fail;
+
+/** Test for {@link ParserImpl}. */
+public class ParserImplTest {
+
+    @Rule public ExpectedException thrown = ExpectedException.none();
+
+    private final boolean isStreamingMode = false;
+    private final TableConfig tableConfig = new TableConfig();
+    private final Catalog catalog = new GenericInMemoryCatalog("MockCatalog", "default");
+    private final CatalogManager catalogManager =
+            CatalogManagerMocks.preparedCatalogManager().defaultCatalog("builtin", catalog).build();
+    private final ModuleManager moduleManager = new ModuleManager();
+    private final FunctionCatalog functionCatalog =
+            new FunctionCatalog(tableConfig, catalogManager, moduleManager);
+    private final PlannerContext plannerContext =
+            new PlannerContext(
+                    tableConfig,
+                    functionCatalog,
+                    catalogManager,
+                    asRootSchema(new CatalogManagerCalciteSchema(catalogManager, isStreamingMode)),
+                    new ArrayList<>());
+
+    private final Supplier<FlinkPlannerImpl> plannerSupplier =
+            () ->
+                    plannerContext.createFlinkPlanner(
+                            catalogManager.getCurrentCatalog(),
+                            catalogManager.getCurrentDatabase());
+
+    private final Parser parser =
+            new ParserImpl(
+                    catalogManager,
+                    plannerSupplier,
+                    () -> plannerSupplier.get().parser(),
+                    t ->
+                            plannerContext.createSqlExprToRexConverter(
+                                    plannerContext.getTypeFactory().buildRelNodeRowType(t)));
+
+    private List<TestSpec> testLegalStatements;
+    private List<TestSpec> testIllegalStatements;
+
+    @Before
+    public void setup() {
+        testLegalStatements =
+                Arrays.asList(
+                        TestSpec.forStatement("ClEaR").expectedSummary("CLEAR"),
+                        TestSpec.forStatement("hElP").expectedSummary("HELP"),
+                        TestSpec.forStatement("qUIT").expectedSummary("QUIT"),
+                        TestSpec.forStatement("ExIT").expectedSummary("EXIT"),
+                        TestSpec.forStatement("REsEt").expectedSummary("RESET"),
+                        TestSpec.forStatement("   SEt ").expectedSummary("SET"),
+                        TestSpec.forStatement("SET execution.runtime-type=batch")
+                                .expectedSummary("SET execution.runtime-type=batch"),
+                        TestSpec.forStatement("SET pipeline.jars = /path/to/test-_-jar.jar")
+                                .expectedSummary("SET pipeline.jars=/path/to/test-_-jar.jar"),
+                        TestSpec.forStatement("USE test.db1").expectedSummary("USE test.db1"),
+                        TestSpec.forStatement("SHOW tables").expectedSummary("SHOW TABLES"));
+
+        testIllegalStatements =
+                Arrays.asList(
+                        TestSpec.forStatement("SET pipeline.name = ' '"),

Review comment:
       We should support this. 




-- 
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 #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 24478272be8cc8034c79f3296fa286b22b856f52 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15353) 
   
   <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] flinkbot commented on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 99c9499a5a4b7f2850fbc0d7ae33f896125a58db 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] flinkbot edited a comment on pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 99c9499a5a4b7f2850fbc0d7ae33f896125a58db Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969) 
   
   <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] wuchong closed pull request #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   


-- 
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 #15265: [FLINK-21836][table-api] Introduce ParseStrategyParser

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14969",
       "triggerID" : "99c9499a5a4b7f2850fbc0d7ae33f896125a58db",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342",
       "triggerID" : "5d6784d65ea57a6bccf4bbcb12186993e78056be",
       "triggerType" : "PUSH"
     }, {
       "hash" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "24478272be8cc8034c79f3296fa286b22b856f52",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d6784d65ea57a6bccf4bbcb12186993e78056be Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=15342) 
   * 24478272be8cc8034c79f3296fa286b22b856f52 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