Source:
protected Node visitShowFunctions(ShowFunctions node, Void context) { ImmutableList.Builder<Expression> rows = ImmutableList.builder(); for (SqlFunction function : metadata.listFunctions(session)) { Signature signature = function.getSignature(); boolean builtIn = signature.getName().getFunctionNamespace().equals(DEFAULT_NAMESPACE); rows.add(row( builtIn ? new StringLiteral(signature.getNameSuffix()) : new StringLiteral(signature.getName().toString()), new StringLiteral(signature.getReturnType().toString()), new StringLiteral(Joiner.on(", ").join(signature.getArgumentTypes())), new StringLiteral(getFunctionType(function)), function.isDeterministic() ? TRUE_LITERAL : FALSE_LITERAL, new StringLiteral(nullToEmpty(function.getDescription())), signature.isVariableArity() ? TRUE_LITERAL : FALSE_LITERAL, builtIn ? TRUE_LITERAL : FALSE_LITERAL, function instanceof SqlInvokedFunction ? new StringLiteral(((SqlInvokedFunction) function).getRoutineCharacteristics().getLanguage().name().toLowerCase(ENGLISH)) : new NullLiteral())); } Map<String, String> columns = ImmutableMap.<String, String>builder() .put("function_name", "Function") .put("return_type", "Return Type") .put("argument_types", "Argument Types") .put("function_type", "Function Type") .put("deterministic", "Deterministic") .put("description", "Description") .put("variable_arity", "Variable Arity") .put("built_in", "Built In") .put("language", "Language") .build(); return simpleQuery( selectAll(columns.entrySet().stream() .map(entry -> aliasedName(entry.getKey(), entry.getValue())) .collect(toImmutableList())), aliased(new Values(rows.build()), "functions", ImmutableList.copyOf(columns.keySet())), ordering( new SortItem( functionCall("lower", identifier("function_name")), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED), ascending("return_type"), ascending("argument_types"), ascending("function_type"))); }

Target:
protected Node visitShowFunctions(ShowFunctions node, Void context) { ImmutableList.Builder<Expression> rows = ImmutableList.builder(); for (SqlFunction function : metadata.listFunctions(session)) { Signature signature = function.getSignature(); boolean builtIn = signature.getName().getFunctionNamespace().equals(DEFAULT_NAMESPACE); rows.add(row( builtIn ? new StringLiteral(signature.getNameSuffix()) : new StringLiteral(signature.getName().toString()), new StringLiteral(signature.getReturnType().toString()), new StringLiteral(Joiner.on(", ").join(signature.getArgumentTypes())), new StringLiteral(getFunctionType(function)), function.isDeterministic() ? TRUE_LITERAL : FALSE_LITERAL, new StringLiteral(nullToEmpty(function.getDescription())), signature.isVariableArity() ? TRUE_LITERAL : FALSE_LITERAL, builtIn ? TRUE_LITERAL : FALSE_LITERAL, function instanceof SqlInvokedFunction ? new StringLiteral(((SqlInvokedFunction) function).getRoutineCharacteristics().getLanguage().name().toLowerCase(ENGLISH)) : new StringLiteral(""))); } Map<String, String> columns = ImmutableMap.<String, String>builder() .put("function_name", "Function") .put("return_type", "Return Type") .put("argument_types", "Argument Types") .put("function_type", "Function Type") .put("deterministic", "Deterministic") .put("description", "Description") .put("variable_arity", "Variable Arity") .put("built_in", "Built In") .put("language", "Language") .build(); return simpleQuery( selectAll(columns.entrySet().stream() .map(entry -> aliasedName(entry.getKey(), entry.getValue())) .collect(toImmutableList())), aliased(new Values(rows.build()), "functions", ImmutableList.copyOf(columns.keySet())), ordering( new SortItem( functionCall("lower", identifier("function_name")), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED), ascending("return_type"), ascending("argument_types"), ascending("function_type"))); }