flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] JingsongLi commented on a change in pull request #12934: [FLINK-18616][table sql/api]Add SHOW CURRENT DDLs
Date Mon, 20 Jul 2020 07:38:25 GMT

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



Mime
View raw message