vladErmakov07 commented on a change in pull request #639:
URL: https://github.com/apache/ignite-3/pull/639#discussion_r802789362
##########
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:
The array element for any command that failed is
Statement.EXECUTE_FAILED (-3).
On the other hand, there can only be one error, and JDBC driver contract
does not regulate it for the case when several queries are failed.
My implementation is the same as the one in Ignite 2: only the error of the
first broken query is sent to the client. The rest of the errors are logged on
the server node.
Maybe we should discuss this behavior.
--
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]