You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/07 09:06:39 UTC

[GitHub] [ignite-3] AMashenkov commented on a change in pull request #309: IGNITE-15107 Integrate DDL support.

AMashenkov commented on a change in pull request #309:
URL: https://github.com/apache/ignite-3/pull/309#discussion_r703325710



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ddl/DdlCommandHandler.java
##########
@@ -0,0 +1,208 @@
+/*
+ * 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.ignite.internal.processors.query.calcite.exec.ddl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.ignite.configuration.schemas.table.IndexColumnView;
+import org.apache.ignite.configuration.schemas.table.TableIndexView;
+import org.apache.ignite.internal.processors.query.calcite.prepare.PlanningContext;
+import org.apache.ignite.internal.processors.query.calcite.prepare.ddl.AlterTableAddCommand;
+import org.apache.ignite.internal.processors.query.calcite.prepare.ddl.AlterTableDropCommand;
+import org.apache.ignite.internal.processors.query.calcite.prepare.ddl.CreateTableCommand;
+import org.apache.ignite.internal.processors.query.calcite.prepare.ddl.DdlCommand;
+import org.apache.ignite.internal.processors.query.calcite.prepare.ddl.DropTableCommand;
+import org.apache.ignite.internal.table.distributed.TableManager;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+import org.apache.ignite.lang.LoggerMessageHelper;
+import org.apache.ignite.schema.Column;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.SchemaTable;
+import org.apache.ignite.schema.builder.PrimaryIndexBuilder;
+import org.apache.ignite.table.Table;
+
+import static org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static org.apache.ignite.internal.util.CollectionUtils.nullOrEmpty;
+import static org.apache.ignite.internal.util.IgniteUtils.isNullOrEmpty;
+import static org.apache.ignite.schema.PrimaryIndex.PRIMARY_KEY_INDEX_NAME;
+
+/** DDL commands handler. */
+public class DdlCommandHandler {
+    /** */
+    private final TableManager tableManager;
+
+    /** */
+    public DdlCommandHandler(TableManager tblManager) {
+        tableManager = tblManager;
+    }
+
+    /** */
+    public void handle(DdlCommand cmd, PlanningContext pctx) throws IgniteInternalCheckedException {
+        validateCommand(cmd);
+
+        if (cmd instanceof CreateTableCommand)
+            handle0((CreateTableCommand)cmd);
+        else if (cmd instanceof DropTableCommand)
+            handle0((DropTableCommand)cmd);
+        else if (cmd instanceof AlterTableAddCommand)
+            handle0((AlterTableAddCommand)cmd);
+        else if (cmd instanceof AlterTableDropCommand)
+            handle0((AlterTableDropCommand)cmd);
+        else {
+            throw new IgniteInternalCheckedException("Unsupported DDL operation [" +
+                "cmdName=" + (cmd == null ? null : cmd.getClass().getSimpleName()) + "; " +
+                "querySql=\"" + pctx.query() + "\"]");
+        }
+    }
+
+    /** Validate command. */
+    private void validateCommand(DdlCommand cmd) {
+        if (isNullOrEmpty(cmd.tableName()))
+            throw new IllegalArgumentException("tableName name is undefined.");
+    }
+
+    /** */
+    private void handle0(CreateTableCommand cmd) throws IgniteInternalCheckedException {

Review comment:
       Let's rename to e.g. handleCreateCmd or smth meaningful.




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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org