static void setFunctionResourceUris(String FUNC_RU, PersistenceManager pm, String funcIds,
      TreeMap<Long, Function> functions)
      throws MetaException {
    String queryText;
    queryText = "select \"FUNC_ID\", \"RESOURCE_TYPE\", \"RESOURCE_URI\" from " +  FUNC_RU
        + " where \"FUNC_ID\" in (" + funcIds + ")"
        + " order by \"FUNC_ID\" asc, \"INTEGER_IDX\" asc";
    loopJoinOrderedResult(pm, functions, queryText, 0, (t, fields) -> {
      ResourceUri resourceUri = new ResourceUri(ResourceType.findByValue((int)fields[1]), (String) fields[2]);
      t.getResourceUris().add(resourceUri);
    });
  }
Merges applies the result of a PM SQL query into a tree of object.
Essentially it's an object join. DN could do this for us, but it issues queries
separately for every object, which is suboptimal.
@param pm
@param tree The object tree, by ID.
@param queryText The query text.
@param keyIndex Index of the Long column corresponding to the map ID in query result rows.
@param func The function that is called on each (object,row) pair with the same id.
@return the count of results returned from the query.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java