morningman commented on a change in pull request #2800: Support new show functions syntax to make user search function more conveniently URL: https://github.com/apache/incubator-doris/pull/2800#discussion_r368301637
########## File path: fe/src/main/java/org/apache/doris/qe/ShowExecutor.java ########## @@ -302,44 +304,77 @@ private void handleShowEngines() { resultSet = new ShowResultSet(showStmt.getMetaData(), rowSet); } - // Handle show function - private void handleShowFunction() throws AnalysisException { - ShowFunctionStmt showStmt = (ShowFunctionStmt) stmt; - + // Handle show functions + private void handleShowFunctions() throws AnalysisException { + ShowFunctionsStmt showStmt = (ShowFunctionsStmt) stmt; Database db = ctx.getCatalog().getDb(showStmt.getDbName()); if (db == null) { ErrorReport.reportAnalysisException(ErrorCode.ERR_BAD_DB_ERROR, showStmt.getDbName()); } - List<Function> functions = db.getFunctions(); + List<Function> functions = showStmt.getIsBuiltin() ? ctx.getCatalog().getBuiltinFunctions() : + db.getFunctions(); - List<List<String>> rowSet = Lists.newArrayList(); + List<List<Comparable>> rowSet = Lists.newArrayList(); for (Function function : functions) { - List<String> row = Lists.newArrayList(); - // signature - row.add(function.getSignature()); - // return type - row.add(function.getReturnType().getPrimitiveType().toString()); - // function type - // intermediate type - if (function instanceof ScalarFunction) { - row.add("Scalar"); - row.add("NULL"); - } else { - row.add("Aggregate"); - AggregateFunction aggFunc = (AggregateFunction) function; - Type intermediateType = aggFunc.getIntermediateType(); - if (intermediateType != null) { - row.add(intermediateType.getPrimitiveType().toString()); - } else { + List<Comparable> row = Lists.newArrayList(); + if (showStmt.getIsVerbose()) { + // signature + row.add(function.getSignature()); + // return type + row.add(function.getReturnType().getPrimitiveType().toString()); + // function type + // intermediate type + if (function instanceof ScalarFunction) { + row.add("Scalar"); row.add("NULL"); + } else { + row.add("Aggregate"); + AggregateFunction aggFunc = (AggregateFunction) function; + Type intermediateType = aggFunc.getIntermediateType(); + if (intermediateType != null) { + row.add(intermediateType.getPrimitiveType().toString()); + } else { + row.add("NULL"); + } } + // property + row.add(function.getProperties()); + } else { + row.add(function.functionName()); + } + + // like predicate + if (showStmt.getWild() == null || showStmt.like(function.functionName())) { + rowSet.add(row); } - // property - row.add(function.getProperties()); - rowSet.add(row); } + + // sort function rows by fisrt column asec Review comment: ```suggestion // sort function rows by first column asc ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org