Search in sources :

Example 26 with AliasModifier

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

the class HiveExecutionFactory 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("int", FunctionModifier.INTEGER);
    // $NON-NLS-1$
    convert.addTypeMapping("bigint", FunctionModifier.BIGINTEGER, FunctionModifier.LONG);
    // $NON-NLS-1$
    convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN);
    // $NON-NLS-1$
    convert.addTypeMapping("double", FunctionModifier.DOUBLE);
    // $NON-NLS-1$
    convert.addTypeMapping("float", FunctionModifier.FLOAT);
    // $NON-NLS-1$
    convert.addTypeMapping("string", FunctionModifier.STRING);
    // $NON-NLS-1$
    convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP);
    // $NON-NLS-1$
    convert.addTypeMapping("binary", FunctionModifier.BLOB, FunctionModifier.VARBINARY);
    // $NON-NLS-1$
    convert.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL);
    // $NON-NLS-1$
    convert.addTypeMapping("date", FunctionModifier.DATE);
    // unsupported types
    // FunctionModifier.TIME,
    // FunctionModifier.CHAR,
    // FunctionModifier.CLOB,
    // FunctionModifier.XML
    registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("&"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("~"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("|"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("^"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("unix_timestamp"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory(), Arrays.asList(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)));
    registerFunctionModifier(SourceSystemFunctions.ARRAY_GET, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            return Arrays.asList(function.getParameters().get(0), '[', function.getParameters().get(1), ']');
        }
    });
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "lower", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "upper", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "positive", INTEGER, DOUBLE);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "positive", DOUBLE, DOUBLE);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "negitive", INTEGER, DOUBLE);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "negitive", DOUBLE, DOUBLE);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "ln", DOUBLE, DOUBLE);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "reverse", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "space", INTEGER, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "split", OBJECT, STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "hex", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "unhex", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "bin", STRING, LONG);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "day", INTEGER, DATE);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "datediff", INTEGER, STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "date_add", INTEGER, STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "date_sub", INTEGER, STRING, INTEGER);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "from_unixtime", STRING, LONG);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "from_unixtime", STRING, LONG, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "unix_timestamp", LONG, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "unix_timestamp", LONG, STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "to_date", STRING, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "from_utc_timestamp", TIMESTAMP, TIMESTAMP, STRING);
    // $NON-NLS-1$
    addPushDownFunction(HIVE, "to_utc_timestamp", TIMESTAMP, TIMESTAMP, STRING);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LEAD", OBJECT, OBJECT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LEAD", OBJECT, OBJECT, INTEGER);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LEAD", OBJECT, OBJECT, INTEGER, OBJECT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LAG", OBJECT, OBJECT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LAG", OBJECT, OBJECT, INTEGER);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LAG", OBJECT, OBJECT, INTEGER, OBJECT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "FIRST_VALUE", OBJECT, OBJECT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "LAST_VALUE", OBJECT, OBJECT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "PERCENT_RANK", FLOAT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "CUME_DIST", FLOAT);
    // $NON-NLS-1$
    addAggregatePushDownFunction(HIVE, "NTILE", LONG, INTEGER);
}
Also used : Function(org.teiid.language.Function) ModFunctionModifier(org.teiid.translator.jdbc.ModFunctionModifier) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) ModFunctionModifier(org.teiid.translator.jdbc.ModFunctionModifier) AliasModifier(org.teiid.translator.jdbc.AliasModifier) ArrayList(java.util.ArrayList) List(java.util.List)

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