Search in sources :

Example 1 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class FunctionTree method findFunctionMethods.

/**
 * Find all function methods with the given name and arg length
 * @param name Function name, case insensitive
 * @param args Number of arguments
 * @return Corresponding form or null if not found
 */
List<FunctionMethod> findFunctionMethods(String name, int args) {
    final List<FunctionMethod> allMatches = new ArrayList<FunctionMethod>();
    List<FunctionMethod> methods = functionsByName.get(name);
    if (methods == null || methods.size() == 0) {
        return allMatches;
    }
    for (FunctionMethod functionMethod : methods) {
        if (functionMethod.getInputParameterCount() == args || functionMethod.isVarArgs() && args >= functionMethod.getInputParameterCount() - 1) {
            allMatches.add(functionMethod);
        }
    }
    return allMatches;
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 2 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class FunctionTree method getFunctionProcedures.

public static FunctionTree getFunctionProcedures(Schema schema) {
    UDFSource dummySource = new UDFSource(Collections.EMPTY_LIST);
    FunctionTree ft = null;
    for (Procedure p : schema.getProcedures().values()) {
        if (p.isFunction() && p.getQueryPlan() != null) {
            if (ft == null) {
                ft = new FunctionTree(schema.getName(), dummySource, false);
            }
            FunctionMethod fm = SQLParserUtil.createFunctionMethod(p);
            FunctionDescriptor fd = ft.addFunction(schema.getName(), dummySource, fm, false);
            fd.setProcedure(p);
        }
    }
    return ft;
}
Also used : Procedure(org.teiid.metadata.Procedure) FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 3 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class SystemSource method addFunction.

private FunctionMethod addFunction(Method method, TeiidFunction f, String name) {
    FunctionMethod func = MetadataFactory.createFunctionFromMethod(name, method);
    // $NON-NLS-1$ //$NON-NLS-2$
    func.setDescription(QueryPlugin.Util.getString(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_description")));
    func.setCategory(f.category());
    for (int i = 0; i < func.getInputParameterCount(); i++) {
        // $NON-NLS-1$ //$NON-NLS-2$
        func.getInputParameters().get(i).setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_param" + (i + 1)));
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    func.getOutputParameter().setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_result"));
    if (f.nullOnNull()) {
        func.setNullOnNull(true);
    }
    func.setDeterminism(f.determinism());
    func.setPushdown(f.pushdown());
    functions.add(func);
    return func;
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 4 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class CompositeMetadataStore method assignOids.

private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) {
    addOid(schema, map);
    for (Table table : schema.getTables().values()) {
        addOid(table, map);
        addOids(table.getColumns(), map);
        addOids(table.getAllKeys(), map);
    }
    for (Procedure proc : schema.getProcedures().values()) {
        addOid(proc, map);
        addOids(proc.getParameters(), map);
        if (proc.getResultSet() != null) {
            addOids(proc.getResultSet().getColumns(), map);
        }
    }
    for (FunctionMethod func : schema.getFunctions().values()) {
        addOid(func, map);
        addOids(func.getInputParameters(), map);
        addOid(func.getOutputParameter(), map);
    }
}
Also used : Table(org.teiid.metadata.Table) Procedure(org.teiid.metadata.Procedure) FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 5 with FunctionMethod

use of org.teiid.metadata.FunctionMethod in project teiid by teiid.

the class SystemSource method addUuidFunction.

private void addUuidFunction() {
    FunctionMethod rand = new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.UUID, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.uuid_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    MISCELLANEOUS, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "uuid", new FunctionParameter[] {}, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.uuid_result_desc")));
    rand.setDeterminism(Determinism.NONDETERMINISTIC);
    functions.add(rand);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Aggregations

FunctionMethod (org.teiid.metadata.FunctionMethod)63 FunctionParameter (org.teiid.metadata.FunctionParameter)31 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)9 Schema (org.teiid.metadata.Schema)6 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)6 IOException (java.io.IOException)5 MetadataStore (org.teiid.metadata.MetadataStore)5 List (java.util.List)4 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)4 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)4 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)3 DeployVDBParameter (org.teiid.jdbc.FakeServer.DeployVDBParameter)3 AggregateAttributes (org.teiid.metadata.AggregateAttributes)3 Procedure (org.teiid.metadata.Procedure)3 UDFSource (org.teiid.query.function.UDFSource)3