use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class TestFunctionMethod method testEquivalence2.
@Test
public void testEquivalence2() {
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter p1 = new FunctionParameter("in", "string");
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout = new FunctionParameter("out", "string");
FunctionMethod m1 = new // $NON-NLS-1$ //$NON-NLS-2$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
"length", // $NON-NLS-1$ //$NON-NLS-2$
"", // $NON-NLS-1$ //$NON-NLS-2$
FunctionCategoryConstants.STRING, // $NON-NLS-1$ //$NON-NLS-2$
"com.metamatrix.query.function.FunctionMethods", // $NON-NLS-1$ //$NON-NLS-2$
"length", new FunctionParameter[] { p1 }, pout);
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter p2 = new FunctionParameter("in", "integer");
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout2 = new FunctionParameter("out", "string");
FunctionMethod m2 = new // $NON-NLS-1$ //$NON-NLS-2$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
"length", // $NON-NLS-1$ //$NON-NLS-2$
"", // $NON-NLS-1$ //$NON-NLS-2$
FunctionCategoryConstants.STRING, // $NON-NLS-1$ //$NON-NLS-2$
"com.metamatrix.query.function.FunctionMethods", // $NON-NLS-1$ //$NON-NLS-2$
"length", new FunctionParameter[] { p2 }, pout2);
UnitTestUtil.helpTestEquivalence(1, m1, m2);
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class SQLConversionVisitor method visit.
public void visit(Function obj) {
FunctionMethod f = obj.getMetadataObject();
if (f != null) {
String nativeQuery = f.getProperty(TEIID_NATIVE_QUERY, false);
if (nativeQuery != null) {
List<Argument> args = new ArrayList<Argument>(obj.getParameters().size());
for (Expression p : obj.getParameters()) {
args.add(new Argument(Direction.IN, p, p.getType(), null));
}
parseNativeQueryParts(nativeQuery, args, buffer, this);
return;
}
}
super.visit(obj);
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class BaseHiveExecutionFactory method addAggregatePushDownFunction.
protected FunctionMethod addAggregatePushDownFunction(String qualifier, String name, String returnType, String... paramTypes) {
FunctionMethod method = addPushDownFunction(qualifier, name, returnType, paramTypes);
AggregateAttributes attr = new AggregateAttributes();
attr.setAnalytic(true);
method.setAggregateAttributes(attr);
return method;
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class TestDynamicImportedMetaData method testImportFunction.
@Test
public void testImportFunction() throws Exception {
MetadataFactory mf = createMetadataFactory("x", new Properties());
Table dup = mf.addTable("dup");
mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
MetadataStore ms = mf.asMetadataStore();
server.deployVDB("test", ms);
// $NON-NLS-1$
Connection conn = server.createConnection("jdbc:teiid:test");
Properties importProperties = new Properties();
importProperties.setProperty(NativeMetadataRepository.IMPORT_PUSHDOWN_FUNCTIONS, Boolean.TRUE.toString());
mf = createMetadataFactory("test", importProperties);
NativeMetadataRepository nmr = new NativeMetadataRepository();
OracleExecutionFactory oef = new OracleExecutionFactory();
oef.start();
DataSource ds = Mockito.mock(DataSource.class);
Mockito.stub(ds.getConnection()).toReturn(conn);
nmr.loadMetadata(mf, oef, ds);
Map<String, FunctionMethod> functions = mf.asMetadataStore().getSchemas().get("TEST").getFunctions();
assertEquals(18, functions.size());
}
use of org.teiid.metadata.FunctionMethod in project teiid by teiid.
the class TableSystemTable method getChildren.
@Override
protected NavigableMap<String, FunctionMethod> getChildren(Schema s, TransformationMetadata metadata) {
// since there is no proper schema for a UDF model, no results will show up for legacy functions
if (s.getName().equals(CoreConstants.SYSTEM_MODEL)) {
// currently all system functions are contributed via alternative mechanisms
// system source, push down functions.
FunctionLibrary library = metadata.getFunctionLibrary();
FunctionTree tree = library.getSystemFunctions();
FunctionTree[] userFuncs = library.getUserFunctions();
TreeMap<String, FunctionMethod> functions = new TreeMap<String, FunctionMethod>(String.CASE_INSENSITIVE_ORDER);
for (FunctionTree userFunc : userFuncs) {
if (userFunc.getSchemaName().equals(CoreConstants.SYSTEM_MODEL)) {
functions.putAll(userFunc.getFunctionsByUuid());
}
}
functions.putAll(tree.getFunctionsByUuid());
return functions;
}
return s.getFunctions();
}
Aggregations