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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/QueryExecutor.java:
##########
@@ -241,6 +254,229 @@ CompletableFuture<AsyncSqlCursor<InternalSqlRow>> 
executeChildQuery(
                 });
     }
 
+    CompletableFuture<AsyncSqlCursor<InternalSqlRow>> executeChildBatch(
+            Query parent,
+            QueryTransactionContext scriptTxContext,
+            int batchOffset,
+            List<ParsedResultWithNextCursorFuture> batch
+    ) {
+        if (IgniteUtils.assertionsEnabled()) {
+            int offsetInBatch = 0;
+            for (ParsedResultWithNextCursorFuture item : batch) {
+                assert item.parsedQuery.queryType() == SqlQueryType.DDL 
+                        : item.parsedQuery.queryType() + " at statement #" + 
(batchOffset + offsetInBatch);
+
+                offsetInBatch++;
+            }
+        }
+
+        if (!busyLock.enterBusy()) {
+            return failedFuture(new NodeStoppingException());
+        }
+
+        List<Query> queries = new ArrayList<>(batch.size());
+
+        try {
+            int offsetInBatch = 0;
+            for (ParsedResultWithNextCursorFuture item : batch) {
+                Query query = new Query(
+                        Instant.ofEpochMilli(clockService.now().getPhysical()),
+                        parent,
+                        item.parsedQuery,
+                        batchOffset + offsetInBatch,
+                        idGenerator.next(),
+                        scriptTxContext,
+                        ArrayUtils.OBJECT_EMPTY_ARRAY,
+                        item.nextCursorFuture
+                );
+
+                offsetInBatch++;
+
+                trackQuery(query, null);
+
+                queries.add(query);
+
+                parent.cancel.attach(query.cancel);
+            }
+        } catch (QueryCancelledException ex) {
+            queries.forEach(query -> query.onError(ex));
+
+            return failedFuture(ex);
+        } finally {
+            busyLock.leaveBusy();
+        }
+
+        List<CompletableFuture<?>> preparedQueryFutures = new 
ArrayList<>(batch.size());
+        for (Query query : queries) {
+            
preparedQueryFutures.add(Programs.SCRIPT_ITEM_PREPARATION.run(query));
+        }
+
+        return CompletableFutures.allOf(preparedQueryFutures)
+                .handle((none, ignored) -> {
+                    List<DdlPlan> dllPlans = new ArrayList<>();
+                    for (Query query : queries) {
+                        QueryPlan plan = query.plan;
+                        if (plan == null) {
+                            assert query.error.get() != null;
+
+                            break;
+                        }
+
+                        dllPlans.add((DdlPlan) plan);
+                    }
+
+                    return dllPlans;
+                })
+                .thenCompose(dllPlans -> {

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]

Reply via email to