vladErmakov07 commented on a change in pull request #639:
URL: https://github.com/apache/ignite-3/pull/639#discussion_r803724276



##########
File path: 
modules/client-handler/src/main/java/org/apache/ignite/client/handler/JdbcQueryEventHandlerImpl.java
##########
@@ -164,8 +175,58 @@ public JdbcQueryEventHandlerImpl(QueryProcessor processor, 
JdbcMetadataCatalog m
     /** {@inheritDoc} */
     @Override
     public CompletableFuture<BatchExecuteResult> 
batchAsync(BatchExecuteRequest req) {
-        return CompletableFuture.completedFuture(new 
BatchExecuteResult(UNSUPPORTED_OPERATION,
-                "ExecuteBatch operation is not implemented yet."));
+        IntList res = new IntArrayList();
+
+        IgniteBiTuple<Integer, String> firstError = new IgniteBiTuple<>();
+        try {
+            for (Query query : req.queries()) {
+                if (query.args() == null) {
+                    executeAndCollectUpdateResult(req, res, query, 
OBJECT_EMPTY_ARRAY, firstError);
+                } else {
+                    for (Object[] arg : query.args()) {
+                        executeAndCollectUpdateResult(req, res, query, arg, 
firstError);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            StringWriter sw = getWriterWithStackTrace(e);
+
+            return CompletableFuture.completedFuture(new 
BatchExecuteResult(Response.STATUS_FAILED,
+                    "Exception while executing query " + 
req.queries().get(0).sql() + ". Error message: " + sw));
+        }
+
+        if (!firstError.isEmpty()) {
+            return CompletableFuture.completedFuture(new BatchExecuteResult(

Review comment:
       I refactored the exception handling. We won't continue with operations 
if the execution of a query ended with an error. Now, the result will always 
contain only positive results of update operations.
   
   updateCounts – an update count or Statement.SUCCESS_NO_INFO for each SQL 
command in the batch prior to the failure for JDBC drivers that stop processing 
after a command failure




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