xtern commented on code in PR #2119:
URL: https://github.com/apache/ignite-3/pull/2119#discussion_r1211173130


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogServiceImpl.java:
##########
@@ -205,13 +215,84 @@ public CompletableFuture<Void> dropTable(DropTableParams 
params) {
     /** {@inheritDoc} */
     @Override
     public CompletableFuture<Void> addColumn(AlterTableAddColumnParams params) 
{
-        return failedFuture(new UnsupportedOperationException("Not implemented 
yet."));
+        if (params.columns().isEmpty()) {
+            return completedFuture(null);
+        }
+
+        return saveUpdate(catalog -> {
+            String schemaName = 
Objects.requireNonNullElse(params.schemaName(), CatalogService.PUBLIC);
+
+            SchemaDescriptor schema = 
Objects.requireNonNull(catalog.schema(schemaName), "No schema found: " + 
schemaName);
+
+            TableDescriptor table = schema.table(params.tableName());
+
+            if (table == null) {
+                throw new TableNotFoundException(schemaName, 
params.tableName());
+            }
+
+            List<TableColumnDescriptor> columnDescriptors = new ArrayList<>();
+
+            for (ColumnParams col : params.columns()) {
+                if (table.column(col.name()) != null) {
+                    throw new ColumnAlreadyExistsException(col.name());
+                }
+
+                columnDescriptors.add(CatalogUtils.fromParams(col));
+            }
+
+            return List.of(
+                    new NewColumnsEntry(table.id(), columnDescriptors)
+            );
+        });
     }
 
     /** {@inheritDoc} */
     @Override
     public CompletableFuture<Void> dropColumn(AlterTableDropColumnParams 
params) {
-        return failedFuture(new UnsupportedOperationException("Not implemented 
yet."));
+        if (params.columns().isEmpty()) {
+            return completedFuture(null);
+        } else if (params.columns().size() > 1 && params.ifColumnExists()) {
+            return failedFuture(new UnsupportedOperationException("Clause 'IF 
NOT EXISTS' is not supported when adding multiple columns."));

Review Comment:
   current behavior for ADD COLUMN differs from DROP COLUMN, which seems 
strange to me. From my point of view it's better to keep the same for `ADD 
COLUMN` :roll_eyes: 



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

Reply via email to