alex-plekhanov commented on a change in pull request #9185:
URL: https://github.com/apache/ignite/pull/9185#discussion_r672187067
##########
File path:
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/ddl/DdlSqlToCommandConverter.java
##########
@@ -226,6 +234,64 @@ private DropTableCommand convertDropTable(SqlDropTable
dropTblNode, PlanningCont
return dropTblCmd;
}
+ /**
+ * Converts a given IgniteSqlAlterTableAddColumn AST to a
AlterTableAddCommand.
+ *
+ * @param alterTblNode Root node of the given AST.
+ * @param ctx Planning context.
+ */
+ private AlterTableAddCommand
convertAlterTableAdd(IgniteSqlAlterTableAddColumn alterTblNode, PlanningContext
ctx) {
+ AlterTableAddCommand alterTblCmd = new AlterTableAddCommand();
+
+ alterTblCmd.schemaName(deriveSchemaName(alterTblNode.name(), ctx));
+ alterTblCmd.tableName(deriveObjectName(alterTblNode.name(), ctx,
"table name"));
+ alterTblCmd.ifTableExists(alterTblNode.ifExists());
+ alterTblCmd.ifColumnNotExists(alterTblNode.ifNotExistsColumn());
+
+ List<ColumnDefinition> cols = new ArrayList<>();
+
+ for (SqlNode colNode : alterTblNode.columns()) {
+ assert colNode instanceof SqlColumnDeclaration :
colNode.getClass();
+
+ SqlColumnDeclaration col = (SqlColumnDeclaration)colNode;
+
+ assert col.name.isSimple();
+
+ String name = col.name.getSimple();
+ RelDataType type = ctx.planner().convert(col.dataType);
+
+ assert col.expression == null : "Unexpected column default value"
+ col.expression;
+
+ cols.add(new ColumnDefinition(name, type, null));
+ }
+
+ alterTblCmd.columns(cols);
+
+ return alterTblCmd;
+ }
+
+ /**
+ * Converts a given IgniteSqlAlterTableDropColumn AST to a
AlterTableDropCommand.
+ *
+ * @param alterTblNode Root node of the given AST.
+ * @param ctx Planning context.
+ */
+ private AlterTableDropCommand
convertAlterTableDrop(IgniteSqlAlterTableDropColumn alterTblNode,
PlanningContext ctx) {
+ AlterTableDropCommand alterTblCmd = new AlterTableDropCommand();
+
+ alterTblCmd.schemaName(deriveSchemaName(alterTblNode.name(), ctx));
+ alterTblCmd.tableName(deriveObjectName(alterTblNode.name(), ctx,
"table name"));
+ alterTblCmd.ifTableExists(alterTblNode.ifExists());
+ alterTblCmd.ifColumnExists(alterTblNode.ifExistsColumn());
+
+ List<String> cols = new ArrayList<>();
Review comment:
Fixed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]