Search in sources :

Example 6 with AliasModifier

use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.

the class IngresExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    // $NON-NLS-1$
    convert.addTypeMapping("tinyint", FunctionModifier.BOOLEAN, FunctionModifier.BYTE);
    // $NON-NLS-1$
    convert.addTypeMapping("smallint", FunctionModifier.SHORT);
    // $NON-NLS-1$
    convert.addTypeMapping("integer", FunctionModifier.INTEGER);
    // $NON-NLS-1$
    convert.addTypeMapping("bigint", FunctionModifier.LONG);
    // $NON-NLS-1$
    convert.addTypeMapping("real", FunctionModifier.FLOAT);
    // $NON-NLS-1$
    convert.addTypeMapping("float", FunctionModifier.DOUBLE);
    // $NON-NLS-1$
    convert.addTypeMapping("decimal(38,19)", FunctionModifier.BIGDECIMAL);
    // $NON-NLS-1$
    convert.addTypeMapping("decimal(15,0)", FunctionModifier.BIGINTEGER);
    // $NON-NLS-1$
    convert.addTypeMapping("date", FunctionModifier.DATE);
    // $NON-NLS-1$
    convert.addTypeMapping("time", FunctionModifier.TIME);
    // $NON-NLS-1$
    convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP);
    // $NON-NLS-1$
    convert.addTypeMapping("char(1)", FunctionModifier.CHAR);
    // $NON-NLS-1$
    convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
    // $NON-NLS-1$
    convert.addTypeMapping("blob", FunctionModifier.BLOB);
    // $NON-NLS-1$
    convert.addTypeMapping("clob", FunctionModifier.CLOB);
    convert.addNumericBooleanConversions();
    convert.setWideningNumericImplicit(true);
    registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("bit_and"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("bit_not"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("bit_or"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("bit_xor"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("current_time"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("current_date"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lowercase"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("uppercase"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day"));
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "bit_add", INTEGER, INTEGER, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "bit_length", INTEGER, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "character_length", STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "charextract", CHAR, STRING, INTEGER);
    // uses ingres date??
    // supportedFunctions.add("date_trunc");
    // supportedFunctions.add("dow");
    // supportedFunctions.add("extract");
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "gmt_timestamp", STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "hash", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "hex", STRING, STRING);
    // do not have byte[] type
    // supportedFunctions.add("intextract");
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "ln", DOUBLE, DOUBLE);
    // see lowercase
    // supportedFunctions.add("lower");
    // supportedFunctions.add("upper");
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "octet_length", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "randomf", FLOAT);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "session_user", STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "size", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "squeeze", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "soundex", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "unhex", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "usercode", STRING);
    // $NON-NLS-1$
    addPushDownFunction(INGRES, "username", STRING);
// ignore
// supportedFunctions.add("uuid_create");
// supportedFunctions.add("uuid_compare");
// supportedFunctions.add("uuid_from_char");
// supportedFunctions.add("uuid_to_char");
}
Also used : AliasModifier(org.teiid.translator.jdbc.AliasModifier)

Example 7 with AliasModifier

use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.

the class InterSystemsCacheExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    // $NON-NLS-1$
    convert.addTypeMapping("tinyint", FunctionModifier.BYTE);
    // $NON-NLS-1$
    convert.addTypeMapping("smallint", FunctionModifier.SHORT);
    // $NON-NLS-1$
    convert.addTypeMapping("integer", FunctionModifier.INTEGER);
    // $NON-NLS-1$
    convert.addTypeMapping("bigint", FunctionModifier.LONG);
    // $NON-NLS-1$
    convert.addTypeMapping("decimal(38,19)", FunctionModifier.BIGDECIMAL);
    // $NON-NLS-1$
    convert.addTypeMapping("decimal(19,0)", FunctionModifier.BIGINTEGER);
    // $NON-NLS-1$
    convert.addTypeMapping("character", FunctionModifier.CHAR);
    // $NON-NLS-1$
    convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
    // $NON-NLS-1$
    convert.addTypeMapping("date", FunctionModifier.DATE);
    // $NON-NLS-1$
    convert.addTypeMapping("time", FunctionModifier.TIME);
    // $NON-NLS-1$
    convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP);
    convert.addNumericBooleanConversions();
    registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("nvl"));
    registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.ACOS, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.ASIN, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.ATAN, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.COS, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.COT, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.CURDATE, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.CURTIME, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.DAYNAME, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.EXP, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.HOUR, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.LOG, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.LOG10, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.LEFT, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.MINUTE, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.MONTH, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.MOD, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.NOW, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.PI, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.QUARTER, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.RIGHT, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.SIN, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.SECOND, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.SQRT, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.TAN, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.TRUNCATE, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.DIVIDE_OP, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            if (function.getType() == TypeFacility.RUNTIME_TYPES.INTEGER || function.getType() == TypeFacility.RUNTIME_TYPES.LONG) {
                Function result = ConvertModifier.createConvertFunction(getLanguageFactory(), function, TypeFacility.getDataTypeName(function.getType()));
                function.setType(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
                return Arrays.asList(result);
            }
            return null;
        }
    });
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "CHARACTER_LENGTH", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "CHAR_LENGTH", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "CHARINDEX", INTEGER, STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "CHARINDEX", INTEGER, STRING, STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "INSTR", INTEGER, STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "INSTR", INTEGER, STRING, STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "IS_NUMERIC", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "REPLICATE", STRING, STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "REVERSE", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "STUFF", STRING, STRING, STRING, INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(INTER_CACHE, "TRIM", STRING, STRING);
}
Also used : Function(org.teiid.language.Function) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) AliasModifier(org.teiid.translator.jdbc.AliasModifier) EscapeSyntaxModifier(org.teiid.translator.jdbc.EscapeSyntaxModifier) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with AliasModifier

use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.

the class ModeShapeExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("UPPER"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("LOWER"));
    registerFunctionModifier(JCR_ISCHILDNODE, new IdentifierFunctionModifier());
    registerFunctionModifier(JCR_ISDESCENDANTNODE, new IdentifierFunctionModifier());
    registerFunctionModifier(JCR_ISSAMENODE, new IdentifierFunctionModifier());
    registerFunctionModifier(JCR_REFERENCE, new IdentifierFunctionModifier());
    registerFunctionModifier(JCR_CONTAINS, new IdentifierFunctionModifier());
    addPushDownFunction(JCR, JCR_ISCHILDNODE, BOOLEAN, STRING, STRING);
    addPushDownFunction(JCR, JCR_ISDESCENDANTNODE, BOOLEAN, STRING, STRING);
    addPushDownFunction(JCR, JCR_ISSAMENODE, BOOLEAN, STRING, STRING);
    addPushDownFunction(JCR, JCR_CONTAINS, BOOLEAN, STRING, STRING);
    addPushDownFunction(JCR, JCR_REFERENCE, BOOLEAN, STRING);
    // $NON-NLS-1$
    LogManager.logTrace(LogConstants.CTX_CONNECTOR, "ModeShape Translator Started");
}
Also used : AliasModifier(org.teiid.translator.jdbc.AliasModifier)

Example 9 with AliasModifier

use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.

the class MySQL5ExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    registerFunctionModifier(SourceSystemFunctions.CHAR, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            // $NON-NLS-1$ //$NON-NLS-2$
            return Arrays.asList("char(", function.getParameters().get(0), " USING ASCII)");
        }
    });
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            Literal intervalType = (Literal) function.getParameters().get(0);
            String interval = ((String) intervalType.getValue()).toUpperCase();
            if (interval.equals(NonReserved.SQL_TSI_FRAC_SECOND)) {
                // $NON-NLS-1$
                intervalType.setValue("MICROSECOND");
                Expression[] args = new Expression[] { function.getParameters().get(1), getLanguageFactory().createLiteral(1000, TypeFacility.RUNTIME_TYPES.INTEGER) };
                // $NON-NLS-1$
                function.getParameters().set(1, getLanguageFactory().createFunction("/", args, TypeFacility.RUNTIME_TYPES.INTEGER));
            }
            return null;
        }
    });
    // $NON-NLS-1$ //$NON-NLS-2$
    addPushDownFunction("mysql", "timestampdiff", TypeFacility.RUNTIME_NAMES.INTEGER, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.TIMESTAMP, TypeFacility.RUNTIME_NAMES.TIMESTAMP);
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            Literal intervalType = (Literal) function.getParameters().get(0);
            String interval = ((String) intervalType.getValue()).toUpperCase();
            if (interval.equals(NonReserved.SQL_TSI_FRAC_SECOND)) {
                // $NON-NLS-1$
                intervalType.setValue("MICROSECOND");
                // $NON-NLS-1$
                return Arrays.asList(function, " * 1000");
            }
            return null;
        }
    });
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.ST_SRID, new AliasModifier("SRID"));
}
Also used : Function(org.teiid.language.Function) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) Literal(org.teiid.language.Literal) AliasModifier(org.teiid.translator.jdbc.AliasModifier) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with AliasModifier

use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.

the class JPA2ExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    setSupportsInnerJoins(true);
    setSupportsOrderBy(true);
    setSupportsSelectDistinct(true);
    setSupportedJoinCriteria(SupportedJoinCriteria.KEY);
    setSupportsOuterJoins(true);
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("current_date"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("current_time"));
}
Also used : AliasModifier(org.teiid.translator.jdbc.AliasModifier)

Aggregations

AliasModifier (org.teiid.translator.jdbc.AliasModifier)26 ArrayList (java.util.ArrayList)17 List (java.util.List)17 FunctionModifier (org.teiid.translator.jdbc.FunctionModifier)17 Function (org.teiid.language.Function)12 ConvertModifier (org.teiid.translator.jdbc.ConvertModifier)8 ModFunctionModifier (org.teiid.translator.jdbc.ModFunctionModifier)5 Expression (org.teiid.language.Expression)4 EscapeSyntaxModifier (org.teiid.translator.jdbc.EscapeSyntaxModifier)4 LocateFunctionModifier (org.teiid.translator.jdbc.LocateFunctionModifier)4 Literal (org.teiid.language.Literal)3 TemplateFunctionModifier (org.teiid.translator.jdbc.TemplateFunctionModifier)3 ConcatFunctionModifier (org.teiid.translator.jdbc.oracle.ConcatFunctionModifier)3 LinkedList (java.util.LinkedList)2 QueryExpression (org.teiid.language.QueryExpression)2 FunctionMethod (org.teiid.metadata.FunctionMethod)2 ExtractFunctionModifier (org.teiid.translator.jdbc.ExtractFunctionModifier)2 AddDiffModifier (org.teiid.translator.jdbc.hsql.AddDiffModifier)2 BasicDBList (com.mongodb.BasicDBList)1 AggregateFunction (org.teiid.language.AggregateFunction)1