private void insertPartitionColPrivilegeInBatch(Map<Long, MPartitionColumnPrivilege> partColumnGrantIdToPrivilege,
      Map<Long, Long> partColumnGrantIdToPartId) throws MetaException {
    int rowCount = partColumnGrantIdToPrivilege.size();
    String columns = "(\"PART_COLUMN_GRANT_ID\",\"AUTHORIZER\",\"COLUMN_NAME\",\"CREATE_TIME\",\"GRANT_OPTION\","
        + "\"GRANTOR\",\"GRANTOR_TYPE\",\"PART_ID\",\"PRINCIPAL_NAME\",\"PRINCIPAL_TYPE\",\"PART_COL_PRIV\")";
    int columnCount = 11;
    BatchExecutionContext batchExecutionContext = new BatchExecutionContext() {
      final Iterator<Map.Entry<Long, MPartitionColumnPrivilege>> it
          = partColumnGrantIdToPrivilege.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, MPartitionColumnPrivilege> entry = it.next();
          MPartitionColumnPrivilege partColumnPrivilege = entry.getValue();
          params[paramIndex++] = entry.getKey();
          params[paramIndex++] = partColumnPrivilege.getAuthorizer();
          params[paramIndex++] = partColumnPrivilege.getColumnName();
          params[paramIndex++] = partColumnPrivilege.getCreateTime();
          params[paramIndex++] = partColumnPrivilege.getGrantOption() ? 1 : 0;
          params[paramIndex++] = partColumnPrivilege.getGrantor();
          params[paramIndex++] = partColumnPrivilege.getGrantorType();
          params[paramIndex++] = partColumnGrantIdToPartId.get(entry.getKey());
          params[paramIndex++] = partColumnPrivilege.getPrincipalName();
          params[paramIndex++] = partColumnPrivilege.getPrincipalType();
          params[paramIndex++] = partColumnPrivilege.getPrivilege();
        }
        executeQuery(batchQueryText, params);
      }
    };
    insertInBatch("\"PART_COL_PRIVS\"", 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