Search in sources :

Example 6 with FunctionMethod

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

the class SystemSource method addAtan2Function.

private void addAtan2Function(String name, String description) {
    functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, // $NON-NLS-1$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
    functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, // $NON-NLS-1$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 7 with FunctionMethod

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

the class SystemSource method addBitFunction.

private void addBitFunction(String functionName, String description, String methodName, int parameters, String resultDescription) {
    FunctionParameter[] paramArray = null;
    if (parameters == 1) {
        paramArray = new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
        new FunctionParameter("integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Bitfunc_arg1")) };
    } else if (parameters == 2) {
        paramArray = new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
        new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Bitfunc2_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
        new FunctionParameter("integer2", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Bitfunc2_arg2")) };
    }
    functions.add(new FunctionMethod(functionName, description, NUMERIC, FUNCTION_CLASS, methodName, paramArray, // $NON-NLS-1$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, resultDescription)));
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 8 with FunctionMethod

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

the class SystemSource method addQuarterFunction.

private void addQuarterFunction(String name, String methodName, String dateDesc, String timestampDesc, String returnType) {
    functions.add(new FunctionMethod(name, dateDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
    new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, dateDesc) }, // $NON-NLS-1$
    new FunctionParameter("result", returnType, dateDesc)));
    functions.add(new FunctionMethod(name, timestampDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
    new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, timestampDesc) }, // $NON-NLS-1$
    new FunctionParameter("result", returnType, timestampDesc)));
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 9 with FunctionMethod

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

the class SystemSource method addDateFunction.

private void addDateFunction(String name, String methodName, String dateDesc, String timestampDesc, String returnType) {
    functions.add(new FunctionMethod(name, dateDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
    new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, dateDesc) }, // $NON-NLS-1$
    new FunctionParameter("result", returnType, dateDesc)));
    functions.add(new FunctionMethod(name, timestampDesc, DATETIME, FUNCTION_CLASS, methodName, new FunctionParameter[] { // $NON-NLS-1$
    new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, timestampDesc) }, // $NON-NLS-1$
    new FunctionParameter("result", returnType, timestampDesc)));
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 10 with FunctionMethod

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

the class ODataSQLVisitor method visit.

@Override
public void visit(Function obj) {
    if (this.executionFactory.getFunctionModifiers().containsKey(obj.getName())) {
        List<?> parts = this.executionFactory.getFunctionModifiers().get(obj.getName()).translate(obj);
        if (parts != null) {
            // $NON-NLS-1$
            throw new AssertionError("not supported");
        }
    }
    String name = obj.getName();
    List<Expression> args = obj.getParameters();
    if (isInfixFunction(name)) {
        this.filter.append(Tokens.LPAREN);
        if (args != null) {
            for (int i = 0; i < args.size(); i++) {
                append(args.get(i));
                if (i < (args.size() - 1)) {
                    this.filter.append(Tokens.SPACE);
                    this.filter.append(infixFunctions.get(name));
                    this.filter.append(Tokens.SPACE);
                }
            }
        }
        this.filter.append(Tokens.RPAREN);
    } else {
        FunctionMethod method = obj.getMetadataObject();
        if (name.startsWith(method.getCategory())) {
            name = name.substring(method.getCategory().length() + 1);
        }
        this.filter.append(name).append(Tokens.LPAREN);
        if (args != null && args.size() != 0) {
            if (SourceSystemFunctions.ENDSWITH.equalsIgnoreCase(name)) {
                append(args.get(1));
                this.filter.append(Tokens.COMMA);
                append(args.get(0));
            } else {
                for (int i = 0; i < args.size(); i++) {
                    append(args.get(i));
                    if (i < args.size() - 1) {
                        this.filter.append(Tokens.COMMA);
                    }
                }
            }
        }
        this.filter.append(Tokens.RPAREN);
    }
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod)

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