private Map<PartitionInfo, ColumnStatistics> getPartitionInfo(Connection dbConn, long tblId,
                                                                 Map<String, ColumnStatistics> partColStatsMap)
          throws SQLException, MetaException {
    List<String> queries = new ArrayList<>();
    StringBuilder prefix = new StringBuilder();
    StringBuilder suffix = new StringBuilder();
    Map<PartitionInfo, ColumnStatistics> partitionInfoMap = new HashMap<>();

    List<String> partKeys = partColStatsMap.keySet().stream().map(
            e -> quoteString(e)).collect(Collectors.toList()
    );

    prefix.append("select \"PART_ID\", \"WRITE_ID\", \"PART_NAME\"  from \"PARTITIONS\" where ");
    suffix.append(" and  \"TBL_ID\" = " + tblId);
    TxnUtils.buildQueryWithINClauseStrings(conf, queries, prefix, suffix,
            partKeys, "\"PART_NAME\"", true, false);

    try (Statement statement = dbConn.createStatement()) {
      for (String query : queries) {
        // Select for update makes sure that the partitions are not modified while the stats are getting updated.
        query = sqlGenerator.addForUpdateClause(query);
        LOG.debug("Execute query: " + query);
        try (ResultSet rs = statement.executeQuery(query)) {
          while (rs.next()) {
            PartitionInfo partitionInfo = new PartitionInfo(rs.getLong(1),
                rs.getLong(2), rs.getString(3));
            partitionInfoMap.put(partitionInfo, partColStatsMap.get(rs.getString(3)));
          }
        }
      }
    }
    return partitionInfoMap;
  }
This class contains the optimizations for MetaStore that rely on direct SQL access to
the underlying database. It should use ANSI SQL and be compatible with common databases
such as MySQL (note that MySQL doesn't use full ANSI mode by default), Postgres, etc.

This class separates out the update part from MetaStoreDirectSql class.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java