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/20 07:01:57 UTC

[GitHub] [flink] fsk119 opened a new pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   *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
   
   *Add show current ddls.*
   
   
   ## Brief change log
   
     - *Modify parser in flink and hive to parse SHOW CURRENT DDLs.*
     - *Add Operation of SHOW CURRENT DDLs and convert sqlNode to corresponding Operation.*
     - *Modify TableEnv to adapt to new Operation and return result according to input Operation type.*
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - *Added test that parser can parse SHOW CURRENT DDLs with flink parser, hive parser and sql command parser.*
     - *Added test that SHOW CURRENT DDLs can return correct result with all kinds of TableEnvironment(TableEnvironmentImpl, StreamTableEnv and BatchTableEnv) and sql client.* 
   
   ## 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 commented on pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c3a5fb2c03a80e2d1a447a23923ce5c6c977c389 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 commented on pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   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 c3a5fb2c03a80e2d1a447a23923ce5c6c977c389 (Mon Jul 20 07:03:27 UTC 2020)
   
    ✅no warnings
   
   <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 #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630",
       "triggerID" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "triggerType" : "PUSH"
     }, {
       "hash" : "a6485e7990e33fdf45e8a18753cbca8749bba262",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "a6485e7990e33fdf45e8a18753cbca8749bba262",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c3a5fb2c03a80e2d1a447a23923ce5c6c977c389 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630) 
   * a6485e7990e33fdf45e8a18753cbca8749bba262 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 #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630",
       "triggerID" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c3a5fb2c03a80e2d1a447a23923ce5c6c977c389 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630) 
   
   <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] godfreyhe commented on a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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



##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/Executor.java
##########
@@ -79,13 +79,23 @@
 	/**
 	 * Lists all registered catalogs.
 	 */
-	List<String> listCatalogs(String sessionid) throws SqlExecutionException;
+	List<String> listCatalogs(String sessionId) throws SqlExecutionException;
+
+	/**
+	 * List current catalog.
+	 */
+	String listCurrentCatalog(String sessionId) throws SqlExecutionException;

Review comment:
       > I don't notice Executor has `executeSql` method...
   > Sounds good to clean up these dulicate method as my next work!
   
   I had opened a pr last week




----------------------------------------------------------------
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] godfreyhe commented on a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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



##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/Executor.java
##########
@@ -79,13 +79,23 @@
 	/**
 	 * Lists all registered catalogs.
 	 */
-	List<String> listCatalogs(String sessionid) throws SqlExecutionException;
+	List<String> listCatalogs(String sessionId) throws SqlExecutionException;
+
+	/**
+	 * List current catalog.
+	 */
+	String listCurrentCatalog(String sessionId) throws SqlExecutionException;
 
 	/**
 	 * Lists all databases in the current catalog.
 	 */
 	List<String> listDatabases(String sessionId) throws SqlExecutionException;
 
+	/**
+	 * List current database.
+	 */
+	String listCurrentDatabase(String sessionId) throws SqlExecutionException;

Review comment:
       ditto

##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/Executor.java
##########
@@ -79,13 +79,23 @@
 	/**
 	 * Lists all registered catalogs.
 	 */
-	List<String> listCatalogs(String sessionid) throws SqlExecutionException;
+	List<String> listCatalogs(String sessionId) throws SqlExecutionException;
+
+	/**
+	 * List current catalog.
+	 */
+	String listCurrentCatalog(String sessionId) throws SqlExecutionException;

Review comment:
       we should not introduce new methods, instead, we can call `executeSql` directly




----------------------------------------------------------------
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] JingsongLi merged pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

Posted by GitBox <gi...@apache.org>.
JingsongLi merged pull request #12934:
URL: https://github.com/apache/flink/pull/12934


   


----------------------------------------------------------------
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] JingsongLi commented on a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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



##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/Executor.java
##########
@@ -79,13 +79,23 @@
 	/**
 	 * Lists all registered catalogs.
 	 */
-	List<String> listCatalogs(String sessionid) throws SqlExecutionException;
+	List<String> listCatalogs(String sessionId) throws SqlExecutionException;
+
+	/**
+	 * List current catalog.
+	 */
+	String listCurrentCatalog(String sessionId) throws SqlExecutionException;

Review comment:
       @fsk119 I think you can create a new PR for cleaning methods in `Executor` first...




----------------------------------------------------------------
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 #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630",
       "triggerID" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c3a5fb2c03a80e2d1a447a23923ce5c6c977c389 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630) 
   
   <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 #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630",
       "triggerID" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "triggerType" : "PUSH"
     }, {
       "hash" : "a6485e7990e33fdf45e8a18753cbca8749bba262",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4768",
       "triggerID" : "a6485e7990e33fdf45e8a18753cbca8749bba262",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a6485e7990e33fdf45e8a18753cbca8749bba262 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4768) 
   
   <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 #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630",
       "triggerID" : "c3a5fb2c03a80e2d1a447a23923ce5c6c977c389",
       "triggerType" : "PUSH"
     }, {
       "hash" : "a6485e7990e33fdf45e8a18753cbca8749bba262",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4768",
       "triggerID" : "a6485e7990e33fdf45e8a18753cbca8749bba262",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c3a5fb2c03a80e2d1a447a23923ce5c6c977c389 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4630) 
   * a6485e7990e33fdf45e8a18753cbca8749bba262 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4768) 
   
   <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] JingsongLi commented on a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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



##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
##########
@@ -1007,8 +1009,12 @@ private TableResult executeOperation(Operation operation) {
 			return TableResultImpl.TABLE_RESULT_OK;
 		} else if (operation instanceof ShowCatalogsOperation) {
 			return buildShowResult("catalog name", listCatalogs());
+		} else if (operation instanceof ShowCurrentCatalogOperation){
+			return buildShowResult("catalog name", new String[]{catalogManager.getCurrentCatalog()});

Review comment:
       `current catalog name`?

##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
##########
@@ -1007,8 +1009,12 @@ private TableResult executeOperation(Operation operation) {
 			return TableResultImpl.TABLE_RESULT_OK;
 		} else if (operation instanceof ShowCatalogsOperation) {
 			return buildShowResult("catalog name", listCatalogs());
+		} else if (operation instanceof ShowCurrentCatalogOperation){
+			return buildShowResult("catalog name", new String[]{catalogManager.getCurrentCatalog()});
 		} else if (operation instanceof ShowDatabasesOperation) {
 			return buildShowResult("database name", listDatabases());
+		} else if (operation instanceof ShowCurrentDatabaseOperation) {
+			return buildShowResult("database name", new String[]{catalogManager.getCurrentDatabase()});

Review comment:
       `current database name`?

##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowCurrentDatabaseOperation.java
##########
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Operation to describe SHOW CURRENT DATABASE operation.
+ */
+public class ShowCurrentDatabaseOperation implements ShowOperation{
+	@Override

Review comment:
       Leave one empty line above.

##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowCurrentCatalog.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.sql.parser.dql;
+
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * SHOW CURRENT CATALOG sql call.
+ */
+public class SqlShowCurrentCatalog extends SqlCall {
+	public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("SHOW CURRENT CATALOG", SqlKind.OTHER);
+
+	public SqlShowCurrentCatalog(SqlParserPos pos) {
+		super(pos);
+	}
+
+	@Override
+	public SqlOperator getOperator() {
+		return OPERATOR;
+	}
+
+	@Override
+	public List<SqlNode> getOperandList() {
+		return Collections.emptyList();
+	}
+
+	@Override
+	public void unparse(
+		SqlWriter writer,

Review comment:
       Two indents instead of one.

##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
##########
@@ -309,13 +309,27 @@ public void setSessionProperty(String sessionId, String key, String value) throw
 		return context.wrapClassLoader(() -> Arrays.asList(tableEnv.listCatalogs()));
 	}
 
+	@Override
+	public String listCurrentCatalog(String sessionId) throws SqlExecutionException {
+		final ExecutionContext<?> context = getExecutionContext(sessionId);
+		final TableEnvironment tableEnv = context.getTableEnvironment();
+		return context.wrapClassLoader(() -> tableEnv.getCurrentCatalog());
+	}
+
 	@Override
 	public List<String> listDatabases(String sessionId) throws SqlExecutionException {
 		final ExecutionContext<?> context = getExecutionContext(sessionId);
 		final TableEnvironment tableEnv = context.getTableEnvironment();
 		return context.wrapClassLoader(() -> Arrays.asList(tableEnv.listDatabases()));
 	}
 
+	@Override
+	public String listCurrentDatabase(String sessionId) throws SqlExecutionException {

Review comment:
       `getCurrentDatabase`?

##########
File path: docs/dev/table/sql/show.md
##########
@@ -55,6 +57,14 @@ tEnv.executeSql("SHOW CATALOGS").print();
 // | default_catalog |
 // +-----------------+
 
+// show current catalog
+tEnv.executeSql("SHOW CURRENT CATALOG").print();
+// +-----------------+
+// |    catalog name |

Review comment:
       current catalog name

##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowCurrentCatalog.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.sql.parser.dql;
+
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * SHOW CURRENT CATALOG sql call.
+ */
+public class SqlShowCurrentCatalog extends SqlCall {
+	public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("SHOW CURRENT CATALOG", SqlKind.OTHER);

Review comment:
       Leave one empty line above.
   
   

##########
File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ShowCurrentCatalogOperation.java
##########
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Operation to describe a SHOW CURRENT CATALOG statement.
+ */
+public class ShowCurrentCatalogOperation implements ShowOperation{
+	@Override

Review comment:
       Leave one empty line above.

##########
File path: docs/dev/table/sql/show.md
##########
@@ -25,12 +25,14 @@ under the License.
 * This will be replaced by the TOC
 {:toc}
 
-SHOW statements are used to list all catalogs, or list all databases in the current catalog, or list all tables/views in the current catalog and the current database, or list all functions including temp system functions, system functions, temp catalog functions and catalog functions in the current catalog and the current database.
+SHOW statements are used to list all catalogs, or list all databases in the current catalog, or list all tables/views in the current catalog and the current database, or list current catalog and database, or list all functions including temp system functions, system functions, temp catalog functions and catalog functions in the current catalog and the current database.

Review comment:
       `or show` or `or get`

##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowCurrentDatabase.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.sql.parser.dql;
+
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+* Show current database.
+ */
+public class SqlShowCurrentDatabase extends SqlCall {
+	public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("SHOW CURRENT DATABASE", SqlKind.OTHER);

Review comment:
       Leave one empty line above.
   
   

##########
File path: flink-table/flink-sql-parser/src/main/java/org/apache/flink/sql/parser/dql/SqlShowCurrentDatabase.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.sql.parser.dql;
+
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+* Show current database.
+ */
+public class SqlShowCurrentDatabase extends SqlCall {
+	public static final SqlSpecialOperator OPERATOR = new SqlSpecialOperator("SHOW CURRENT DATABASE", SqlKind.OTHER);
+
+	public SqlShowCurrentDatabase(SqlParserPos pos) {
+		super(pos);
+	}
+
+	@Override
+	public SqlOperator getOperator() {
+		return OPERATOR;
+	}
+
+	@Override
+	public List<SqlNode> getOperandList() {
+		return Collections.EMPTY_LIST;
+	}
+
+	@Override
+	public void unparse(
+		SqlWriter writer,

Review comment:
       Two indents instead of one. Others should be the same.

##########
File path: docs/dev/table/sql/show.zh.md
##########
@@ -274,4 +308,4 @@ SHOW VIEWS
 SHOW FUNCTIONS
 {% endhighlight %}
 
-展示所有的 function,包括:临时系统 function, 系统 function, 临时 catalog function,当前 catalog 和 database 中的 catalog function。
\ No newline at end of file
+展示所有的 function,包括:临时系统 function, 系统 function, 临时 catalog function,当前 catalog 和 database 中的 catalog function。

Review comment:
       What is the difference?

##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
##########
@@ -309,13 +309,27 @@ public void setSessionProperty(String sessionId, String key, String value) throw
 		return context.wrapClassLoader(() -> Arrays.asList(tableEnv.listCatalogs()));
 	}
 
+	@Override
+	public String listCurrentCatalog(String sessionId) throws SqlExecutionException {

Review comment:
       `getCurrentCatalog`?

##########
File path: docs/dev/table/sql/show.md
##########
@@ -63,6 +73,14 @@ tEnv.executeSql("SHOW DATABASES").print();
 // | default_database |
 // +------------------+
 
+// show current database
+tEnv.executeSql("SHOW CURRENT DATABASE").print();
+// +------------------+
+// |    database name |

Review comment:
       current database name




----------------------------------------------------------------
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] godfreyhe commented on a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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



##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/Executor.java
##########
@@ -79,13 +79,23 @@
 	/**
 	 * Lists all registered catalogs.
 	 */
-	List<String> listCatalogs(String sessionid) throws SqlExecutionException;
+	List<String> listCatalogs(String sessionId) throws SqlExecutionException;
+
+	/**
+	 * List current catalog.
+	 */
+	String listCurrentCatalog(String sessionId) throws SqlExecutionException;

Review comment:
       https://github.com/apache/flink/pull/12923




----------------------------------------------------------------
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 a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs

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



##########
File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/Executor.java
##########
@@ -79,13 +79,23 @@
 	/**
 	 * Lists all registered catalogs.
 	 */
-	List<String> listCatalogs(String sessionid) throws SqlExecutionException;
+	List<String> listCatalogs(String sessionId) throws SqlExecutionException;
+
+	/**
+	 * List current catalog.
+	 */
+	String listCurrentCatalog(String sessionId) throws SqlExecutionException;

Review comment:
       I don't notice Executor has `executeSql`  method... 
   Sounds good to clean up these dulicate method as my next work!




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