Search in sources :

Example 16 with FunctionMethod

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);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter) Test(org.junit.Test)

Example 17 with FunctionMethod

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);
}
Also used : ArrayList(java.util.ArrayList) FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 18 with FunctionMethod

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;
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) AggregateAttributes(org.teiid.metadata.AggregateAttributes)

Example 19 with FunctionMethod

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());
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) OracleExecutionFactory(org.teiid.translator.jdbc.oracle.OracleExecutionFactory) Table(org.teiid.metadata.Table) MetadataFactory(org.teiid.metadata.MetadataFactory) NativeMetadataRepository(org.teiid.query.metadata.NativeMetadataRepository) Connection(java.sql.Connection) FunctionMethod(org.teiid.metadata.FunctionMethod) Properties(java.util.Properties) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 20 with FunctionMethod

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();
}
Also used : FunctionTree(org.teiid.query.function.FunctionTree) FunctionLibrary(org.teiid.query.function.FunctionLibrary) FunctionMethod(org.teiid.metadata.FunctionMethod) TreeMap(java.util.TreeMap)

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