Java 类com.facebook.presto.metadata.SqlFunction 实例源码

项目:presto-cuebiq-functions    文件:UdfFactory.java   
@Override
public List<SqlFunction> listFunctions() {
    FunctionListBuilder builder = new FunctionListBuilder();
    try {
        List<Class<?>> classes = getFunctionClasses();
        addFunctions(builder, classes);
    } catch (IOException e) {
        System.out.println("Could not load classes from jar file: " + e);
        return ImmutableList.of();
    }

    return builder.getFunctions();
}
项目:hmmongo    文件:ViterbiFunctionFactory.java   
@Override
public List<SqlFunction> listFunctions() {

    ViterbiFunction.setConfig(viterbiConfig);

    return new FunctionListBuilder(typeManager)
        .scalar(ViterbiFunction.class)
        .getFunctions();
}
项目:presto    文件:StatementAnalyzer.java   
@Override
protected RelationType visitShowFunctions(ShowFunctions node, AnalysisContext context)
{
    ImmutableList.Builder<Expression> rows = ImmutableList.builder();
    for (SqlFunction function : metadata.listFunctions()) {
        if (function.getSignature().getKind() == APPROXIMATE_AGGREGATE) {
            continue;
        }
        rows.add(row(
                new StringLiteral(function.getSignature().getName()),
                new StringLiteral(function.getSignature().getReturnType().toString()),
                new StringLiteral(Joiner.on(", ").join(function.getSignature().getArgumentTypes())),
                new StringLiteral(getFunctionType(function)),
                function.isDeterministic() ? TRUE_LITERAL : FALSE_LITERAL,
                new StringLiteral(nullToEmpty(function.getDescription()))));
    }

    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")
            .build();

    Query query = 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(
                    ascending("function_name"),
                    ascending("return_type"),
                    ascending("argument_types"),
                    ascending("function_type")));

    return process(query, context);
}
项目:presto    文件:StatementAnalyzer.java   
private static String getFunctionType(SqlFunction function)
{
    FunctionKind kind = function.getSignature().getKind();
    switch (kind) {
        case AGGREGATE:
        case APPROXIMATE_AGGREGATE:
            return "aggregate";
        case WINDOW:
            return "window";
        case SCALAR:
            return "scalar";
    }
    throw new IllegalArgumentException("Unsupported function kind: " + kind);
}
项目:presto    文件:RowParametricType.java   
public List<SqlFunction> createFunctions(Type type)
{
    RowType rowType = checkType(type, RowType.class, "type");
    ImmutableList.Builder<SqlFunction> builder = ImmutableList.builder();
    List<RowField> fields = rowType.getFields();
    for (int i = 0; i < fields.size(); i++) {
        RowField field = fields.get(i);
        int index = i;
        field.getName()
                .ifPresent(name -> builder.add(new RowFieldReference(rowType, field.getType(), index, field.getName().get())));
    }
    return builder.build();
}
项目:presto    文件:AbstractTestFunctions.java   
protected void registerScalar(Class<?> clazz)
{
    Metadata metadata = functionAssertions.getMetadata();
    List<SqlFunction> functions = new FunctionListBuilder(metadata.getTypeManager())
            .scalar(clazz)
            .getFunctions();
    metadata.getFunctionRegistry().addFunctions(functions);
}
项目:presto    文件:MLFunctionFactory.java   
@Override
public List<SqlFunction> listFunctions()
{
    return new FunctionListBuilder(typeManager)
            .aggregate(LearnClassifierAggregation.class)
            .aggregate(LearnVarcharClassifierAggregation.class)
            .aggregate(LearnRegressorAggregation.class)
            .aggregate(LearnLibSvmClassifierAggregation.class)
            .aggregate(LearnLibSvmVarcharClassifierAggregation.class)
            .aggregate(LearnLibSvmRegressorAggregation.class)
            .aggregate(EvaluateClassifierPredictionsAggregation.class)
            .scalar(MLFunctions.class)
            .getFunctions();
}
项目:presto    文件:TeradataFunctionFactory.java   
@Override
public List<SqlFunction> listFunctions()
{
    return new FunctionListBuilder(typeManager)
            .scalar(TeradataStringFunctions.class)
            .scalar(TeradataDateFunctions.class)
            .getFunctions();
}
项目:presto    文件:GenericAggregationFunctionFactory.java   
private GenericAggregationFunctionFactory(List<SqlFunction> aggregations)
{
    this.aggregations = ImmutableList.copyOf(requireNonNull(aggregations, "aggregations is null"));
}
项目:presto    文件:GenericAggregationFunctionFactory.java   
@Override
public List<SqlFunction> listFunctions()
{
    return aggregations;
}
项目:presto    文件:FunctionAssertions.java   
public FunctionAssertions addFunctions(List<SqlFunction> functionInfos)
{
    metadata.addFunctions(functionInfos);
    return this;
}