korlov42 commented on code in PR #1134:
URL: https://github.com/apache/ignite-3/pull/1134#discussion_r994376798


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java:
##########
@@ -286,38 +286,42 @@ private CompletableFuture<Boolean> 
addColumnInternal(String fullName, List<Colum
 
         return tableManager.alterTableAsync(
                 fullName,
-                chng -> chng.changeColumns(cols -> {
-                    ret.set(true); // Reset state if closure have been 
restarted.
+                chng -> {
+                    chng.changeColumns(cols -> {
+                        ret.set(true); // Reset state if closure have been 
restarted.
 
-                    Map<String, String> colNamesToOrders = 
columnOrdersToNames(chng.columns());
+                        Map<String, String> colNamesToOrders = 
columnOrdersToNames(chng.columns());
 
-                    List<ColumnDefinition> colsDef0;
+                        List<ColumnDefinition> colsDef0;
 
-                    if (ignoreColumnExistance) {
-                        colsDef0 = colsDef.stream().filter(k -> {
-                            if (colNamesToOrders.containsKey(k.name())) {
-                                ret.set(false);
+                        if (ignoreColumnExistance) {
+                            colsDef0 = colsDef.stream().filter(k -> {
+                                if (colNamesToOrders.containsKey(k.name())) {
+                                    ret.set(false);
 
-                                return false;
-                            } else {
-                                return true;
-                            }
-                        }).collect(Collectors.toList());
-                    } else {
-                        colsDef.stream()
-                                .filter(k -> 
colNamesToOrders.containsKey(k.name()))
-                                .findAny()
-                                .ifPresent(c -> {
-                                    throw new 
ColumnAlreadyExistsException(c.name());
-                                });
-
-                        colsDef0 = colsDef;
-                    }
+                                    return false;
+                                } else {
+                                    return true;
+                                }
+                            }).collect(Collectors.toList());
+                        } else {
+                            colsDef.stream()
+                                    .filter(k -> 
colNamesToOrders.containsKey(k.name()))
+                                    .findAny()
+                                    .ifPresent(c -> {
+                                        throw new 
ColumnAlreadyExistsException(c.name());
+                                    });
+
+                            colsDef0 = colsDef;
+                        }
 
-                    for (ColumnDefinition col : colsDef0) {
-                        cols.create(col.name(), colChg -> 
convertColumnDefinition(col, colChg));
-                    }
-                })
+                        for (ColumnDefinition col : colsDef0) {
+                            cols.create(col.name(), colChg -> 
convertColumnDefinition(col, colChg));
+                        }
+                    });
+
+                    return ret.get();

Review Comment:
   You can't reuse the same result you're going to return to the user, because 
the rules are different:
   
   - the result of the whole operation is `true` if _all_ columns have been 
added
   - the result of the change closure is `true` if _at least one_ column has 
been added (otherwise we won't update the schema version)



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