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;
}
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;
}
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;
}
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);
}
}
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);
}
Aggregations