private void insertPartitionInBatch(Map<Long, MPartition> partIdToPartition, Map<Long, Long> partIdToSdId)
      throws MetaException {
    int rowCount = partIdToPartition.size();
    String columns = "(\"PART_ID\",\"CREATE_TIME\",\"LAST_ACCESS_TIME\",\"PART_NAME\",\"SD_ID\",\"TBL_ID\","
        + "\"WRITE_ID\")";
    int columnCount = 7;
    BatchExecutionContext batchExecutionContext = new BatchExecutionContext() {
      final Iterator<Map.Entry<Long, MPartition>> it = partIdToPartition.entrySet().iterator();
      @Override
      public void execute(String batchQueryText, int batchRowCount) throws MetaException {
        Object[] params = new Object[batchRowCount * columnCount];
        int paramIndex = 0;
        for (int index = 0; index < batchRowCount; index++) {
          Map.Entry<Long, MPartition> entry = it.next();
          MPartition partition = entry.getValue();
          params[paramIndex++] = entry.getKey();
          params[paramIndex++] = partition.getCreateTime();
          params[paramIndex++] = partition.getLastAccessTime();
          params[paramIndex++] = partition.getPartitionName();
          params[paramIndex++] = partIdToSdId.get(entry.getKey());
          params[paramIndex++] = partition.getTable().getId();
          params[paramIndex++] = partition.getWriteId();
        }
        executeQuery(batchQueryText, params);
      }
    };
    insertInBatch("\"PARTITIONS\"", columns, columnCount, rowCount, batchExecutionContext);
  }
Interface to execute multiple row insert query in batch for direct SQL
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlInsertPart.java