[GitHub] [flink] danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner
danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner URL: https://github.com/apache/flink/pull/9093#discussion_r302810245 ## File path: flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/internal/TableEnvImpl.scala ## @@ -457,6 +458,23 @@ abstract class TableEnvImpl( registerCatalogTableInternal(operation.getTablePath, operation.getCatalogTable, operation.isIgnoreIfExists) + case dropTable: SqlDropTable => +val name = dropTable.fullTableName() +val isIfExists = dropTable.getIfExists +val paths = catalogManager.getFullTablePath(name.toList) +val catalog = getCatalog(paths(0)) +if (!catalog.isPresent) { + if (!isIfExists) { +throw new TableException(s"Catalog ${paths(0)} does not exist.") + } +} else { + try +catalog.get().dropTable(new ObjectPath(paths(1), paths(2)), isIfExists) + catch { +case e: TableNotExistException => + throw new TableException(e.getMessage) + } +} case _ => throw new TableException( "Unsupported SQL query! sqlUpdate() only accepts SQL statements of type INSERT.") Review comment: Updated 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner
danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner URL: https://github.com/apache/flink/pull/9093#discussion_r302810065 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/PlannerBase.scala ## @@ -112,24 +114,26 @@ abstract class PlannerBase( val planner = getFlinkPlanner // parse the sql query val parsed = planner.parse(stmt) -if (null != parsed && parsed.getKind.belongsTo(SqlKind.QUERY)) { - // validate the sql query - val validated = planner.validate(parsed) - // transform to a relational tree - val relational = planner.rel(validated) - List(new PlannerQueryOperation(relational.project())) -} else if (null != parsed && parsed.isInstanceOf[SqlInsert]) { - val insert = parsed.asInstanceOf[SqlInsert] - // validate the SQL query - val query = insert.getSource - val validatedQuery = planner.validate(query) - val sinkOperation = new CatalogSinkModifyOperation( -insert.getTargetTable.asInstanceOf[SqlIdentifier].names, -new PlannerQueryOperation(planner.rel(validatedQuery).rel) - ) - List(sinkOperation) -} else { - throw new TableException(s"Unsupported query: $stmt") +parsed match { + case insert: SqlInsert => +// get name of sink table +val targetTablePath = insert.getTargetTable.asInstanceOf[SqlIdentifier].names + +List(new CatalogSinkModifyOperation(targetTablePath, + SqlToOperationConverter.convert(planner, +insert.getSource).asInstanceOf[PlannerQueryOperation]) + .asInstanceOf[Operation]).asJava Review comment: Yes, cause we already have `JavaConversions._` 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner
danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner URL: https://github.com/apache/flink/pull/9093#discussion_r302809445 ## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/PlannerBase.scala ## @@ -112,24 +114,26 @@ abstract class PlannerBase( val planner = getFlinkPlanner // parse the sql query val parsed = planner.parse(stmt) -if (null != parsed && parsed.getKind.belongsTo(SqlKind.QUERY)) { - // validate the sql query - val validated = planner.validate(parsed) - // transform to a relational tree - val relational = planner.rel(validated) - List(new PlannerQueryOperation(relational.project())) -} else if (null != parsed && parsed.isInstanceOf[SqlInsert]) { - val insert = parsed.asInstanceOf[SqlInsert] - // validate the SQL query - val query = insert.getSource - val validatedQuery = planner.validate(query) - val sinkOperation = new CatalogSinkModifyOperation( -insert.getTargetTable.asInstanceOf[SqlIdentifier].names, -new PlannerQueryOperation(planner.rel(validatedQuery).rel) - ) - List(sinkOperation) -} else { - throw new TableException(s"Unsupported query: $stmt") +parsed match { + case insert: SqlInsert => +// get name of sink table +val targetTablePath = insert.getTargetTable.asInstanceOf[SqlIdentifier].names + +List(new CatalogSinkModifyOperation(targetTablePath, Review comment: Done 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner
danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner URL: https://github.com/apache/flink/pull/9093#discussion_r302809209 ## File path: flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/catalog/CatalogTableITCase.scala ## @@ -440,6 +440,103 @@ class CatalogTableITCase(isStreaming: Boolean) { execJob("testJob") assertEquals(TestCollectionTableFactory.RESULT.sorted, sourceData.sorted) } + Review comment: Already added 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner
danny0405 commented on a change in pull request #9093: [FLINK-13220][FLINK-13211] [flink-table] Add drop table support for flink planner and add DDL support for blink planner URL: https://github.com/apache/flink/pull/9093#discussion_r302808998 ## File path: flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/ddl/DropTableOperation.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.table.operations.ddl; + +import org.apache.flink.table.operations.Operation; +import org.apache.flink.table.operations.OperationUtils; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Operation to describe a DROP TABLE statement. + */ +public class DropTableOperation implements DropOperation { + private final String[] tableName; + private final boolean ifExists; + + public DropTableOperation(String[] tableName, boolean ifExists) { + this.tableName = tableName; + this.ifExists = ifExists; + } + + public String[] getTableName() { + return this.tableName; + } + + public boolean isIfExists() { + return this.ifExists; + } + + @Override + public String asSummaryString() { + Map params = new LinkedHashMap<>(); + params.put("IfExists", ifExists); Review comment: Added 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: us...@infra.apache.org With regards, Apache Git Services