ayushtkn commented on code in PR #4786: URL: https://github.com/apache/hive/pull/4786#discussion_r1359260885
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java: ########## @@ -11579,6 +11579,33 @@ public Function getFunction(String catName, String dbName, String funcName) thro @Override public List<Function> getAllFunctions(String catName) throws MetaException { + try { + return getFunctionsInternal(catName); + } catch (NoSuchObjectException e) { + throw new RuntimeException(e); + } + } + + protected List<Function> getFunctionsInternal(String catalogName) + throws MetaException, NoSuchObjectException { + return new GetListHelper<Function>(catalogName, "", "", true, true) { + @Override + protected List<Function> getSqlResult(GetHelper<List<Function>> ctx) throws MetaException { + return directSql.getFunctions(catalogName); + } + @Override + protected List<Function> getJdoResult(GetHelper<List<Function>> ctx) throws MetaException { + try { + return getAllFunctionsViaJDO(catalogName); + } catch (Exception e) { + LOG.error("Failed to convert to funcs", e); Review Comment: nit ``funcs`` -> ``functions`` ########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java: ########## @@ -514,6 +514,21 @@ public void apply(SerDeInfo t, Object[] fields) { } } + 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 + "" Review Comment: why "" empty concat? ########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDirectSqlUtils.java: ########## @@ -514,6 +514,21 @@ public void apply(SerDeInfo t, Object[] fields) { } } + 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, new ApplyFunc<Function>() { + @Override + public void apply(Function t, Object[] fields) { + ResourceUri resourceUri = new ResourceUri(ResourceType.findByValue((int)fields[1]), (String) fields[2]); + t.getResourceUris().add(resourceUri); + }}); Review Comment: can use lambda ``` loopJoinOrderedResult(pm, functions, queryText, 0, (t, fields) -> { ResourceUri resourceUri = new ResourceUri(ResourceType.findByValue((int)fields[1]), (String) fields[2]); t.getResourceUris().add(resourceUri); }); ``` ########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java: ########## @@ -3064,4 +3067,104 @@ public Map<String, Map<String, String>> updatePartitionColumnStatisticsBatch( long csId = updateStat.getNextCSIdForMPartitionColumnStatistics(numStats); return updateStat.updatePartitionColumnStatistics(partColStatsMap, tbl, csId, validWriteIds, writeId, listeners); } + + public List<Function> getFunctions(String catName) throws MetaException { + List<Long> funcIds = getFunctionIds(catName); + // Get full objects. For Oracle/etc. do it in batches. + return Batchable.runBatched(batchSize, funcIds, new Batchable<Long, Function>() { + @Override + public List<Function> run(List<Long> input) throws MetaException { + return getFunctionsFromFunctionIds(input, catName); + } + }); + } + + private List<Function> getFunctionsFromFunctionIds(List<Long> funcIdList, String catName) throws MetaException { + String funcIds = getIdListForIn(funcIdList); + final int funcIdIndex = 0; + final int funcNameIndex = 1; + final int dbNameIndex = 2; + final int funcClassNameIndex = 3; + final int funcOwnerNameIndex = 4; + final int funcOwerTypeIndex = 5; Review Comment: typo ``` funcOwnerType ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org