@SuppressWarnings({
    "squid:S3776"
  }) // ignore Cognitive Complexity of methods should not be too high
  private void insertRelationalTabletByGroup(Map<SessionConnection, Tablet> relationalTabletGroup)
      throws IoTDBConnectionException, StatementExecutionException {
    List<CompletableFuture<Void>> completableFutures =
        relationalTabletGroup.entrySet().stream()
            .map(
                entry -> {
                  SessionConnection connection = entry.getKey();
                  Tablet subTablet = entry.getValue();
                  return CompletableFuture.runAsync(
                      () -> {
                        TSInsertTabletReq request = genTSInsertTabletReq(subTablet, false, false);
                        request.setWriteToTable(true);
                        request.setColumnCategories(
                            subTablet.getColumnTypes().stream()
                                .map(t -> (byte) t.ordinal())
                                .collect(Collectors.toList()));
                        InsertConsumer<TSInsertTabletReq> insertConsumer =
                            SessionConnection::insertTablet;
                        try {
                          insertConsumer.insert(connection, request);
                        } catch (RedirectException e) {
                          List<TEndPoint> endPointList = e.getEndPointList();
                          Map<IDeviceID, TEndPoint> endPointMap = new HashMap<>();
                          for (int i = 0; i < endPointList.size(); i++) {
                            if (endPointList.get(i) != null) {
                              endPointMap.put(subTablet.getDeviceID(i), endPointList.get(i));
                            }
                          }
                          endPointMap.forEach(this::handleRedirection);
                        } catch (StatementExecutionException e) {
                          throw new CompletionException(e);
                        } catch (IoTDBConnectionException e) {
                          // remove the broken session
                          removeBrokenSessionConnection(connection);
                          try {
                            insertConsumer.insert(defaultSessionConnection, request);
                          } catch (IoTDBConnectionException | StatementExecutionException ex) {
                            throw new CompletionException(ex);
                          } catch (RedirectException ignored) {
                          }
                        }
                      },
                      OPERATION_EXECUTOR);
                })
            .collect(Collectors.toList());

    StringBuilder errMsgBuilder = new StringBuilder();
    for (CompletableFuture<Void> completableFuture : completableFutures) {
      try {
        completableFuture.join();
      } catch (CompletionException completionException) {
        Throwable cause = completionException.getCause();
        logger.error("Meet error when async insert!", cause);
        if (cause instanceof IoTDBConnectionException) {
          throw (IoTDBConnectionException) cause;
        } else {
          if (errMsgBuilder.length() > 0) {
            errMsgBuilder.append(";");
          }
          errMsgBuilder.append(cause.getMessage());
        }
      }
    }
    if (errMsgBuilder.length() > 0) {
      throw new StatementExecutionException(errMsgBuilder.toString());
    }
  }
insert a relational Tablet. Note: This method is for internal use only, we do not guarantee
compatibility with subsequent versions.

@param tablet data batch
iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java