use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.
the class ImpalaExecutionFactory 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);
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("unix_timestamp"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("isnull"));
// $NON-NLS-1$ //$NON-NLS-2$
registerFunctionModifier("string_agg", new AliasModifier("group_concat"));
// $NON-NLS-1$
addPushDownFunction(IMPALA, "lower", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "upper", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "positive", INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "positive", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "negitive", INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "negitive", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "ln", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "reverse", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "space", STRING, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hex", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unhex", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "bin", STRING, LONG);
// date functions
// $NON-NLS-1$
addPushDownFunction(IMPALA, "add_months", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "adddate", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "date_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "date_part", INTEGER, STRING, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "date_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "datediff", INTEGER, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "day", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "dayofyear", INTEGER, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "days_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "extract", INTEGER, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "from_unixtime", STRING, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "from_unixtime", STRING, LONG, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "from_utc_timestamp", TIMESTAMP, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hour", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "hours_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "microseconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "microseconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "milliseconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minute", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "minutes_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "month", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "months_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "nanoseconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "second", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "seconds_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "subdate", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "to_date", STRING, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "to_utc_timestamp", TIMESTAMP, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "trunc", TIMESTAMP, TIMESTAMP, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unix_timestamp", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unix_timestamp", INTEGER, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "unix_timestamp", INTEGER, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weekofyear", INTEGER, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "weeks_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_add", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_add", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_sub", TIMESTAMP, TIMESTAMP, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "years_sub", TIMESTAMP, TIMESTAMP, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "conv", STRING, LONG, INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "greatest", STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "greatest", TIMESTAMP, TIMESTAMP, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "greatest", LONG, LONG, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "least", STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "least", TIMESTAMP, TIMESTAMP, TIMESTAMP);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "least", LONG, LONG, LONG);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "log2", STRING, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "pow", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "quotient", INTEGER, INTEGER, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "radians", DOUBLE, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "sign", INTEGER, DOUBLE);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "parse_url", STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "regexp_extract", STRING, STRING, STRING, INTEGER);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "regexp_replace", STRING, STRING, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "group_concat", STRING, STRING, STRING).setAggregateAttributes(new AggregateAttributes());
// $NON-NLS-1$
addPushDownFunction(IMPALA, "concat_ws", STRING, STRING, STRING).setVarArgs(true);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "concat", STRING, STRING).setVarArgs(true);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "initcap", STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "instr", INTEGER, STRING, STRING);
// $NON-NLS-1$
addPushDownFunction(IMPALA, "find_in_set", INTEGER, STRING, STRING);
// standard function form of several predicates
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction(IMPALA, "ilike", BOOLEAN, STRING, STRING).setProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, "($1 ilike $2)");
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction(IMPALA, "rlike", BOOLEAN, STRING, STRING).setProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, "($1 rlike $2)");
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction(IMPALA, "iregexp", BOOLEAN, STRING, STRING).setProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, "($1 iregexp $2)");
}
use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.
the class ActianVectorInHadoopExecutionFactory method start.
@Override
public void start() throws TranslatorException {
super.start();
ConvertModifier convertModifier = new ConvertModifier();
// $NON-NLS-1$
convertModifier.addTypeMapping("CHAR(1)", FunctionModifier.CHAR);
// $NON-NLS-1$
convertModifier.addTypeMapping("VARCHAR", FunctionModifier.STRING);
// $NON-NLS-1$
convertModifier.addTypeMapping("NVARCHAR", FunctionModifier.STRING);
// $NON-NLS-1$
convertModifier.addTypeMapping("INTEGER1", FunctionModifier.BYTE);
// $NON-NLS-1$
convertModifier.addTypeMapping("INTEGER2", FunctionModifier.SHORT);
// $NON-NLS-1$
convertModifier.addTypeMapping("INTEGER4", FunctionModifier.INTEGER);
// $NON-NLS-1$
convertModifier.addTypeMapping("INTEGER8", FunctionModifier.LONG);
// $NON-NLS-1$
convertModifier.addTypeMapping("DECIMAL", FunctionModifier.BIGDECIMAL);
// $NON-NLS-1$
convertModifier.addTypeMapping("MONEY", FunctionModifier.BIGDECIMAL);
// $NON-NLS-1$
convertModifier.addTypeMapping("FLOAT", FunctionModifier.DOUBLE);
// $NON-NLS-1$
convertModifier.addTypeMapping("FLOAT4", FunctionModifier.FLOAT);
// $NON-NLS-1$
convertModifier.addTypeMapping("ANSIDATE", FunctionModifier.DATE);
// $NON-NLS-1$
convertModifier.addTypeMapping("TIME WITHOUT TIME ZONE", FunctionModifier.TIME);
// $NON-NLS-1$
convertModifier.addTypeMapping("TIME WITH TIME ZONE", FunctionModifier.TIME);
// $NON-NLS-1$
convertModifier.addTypeMapping("TIME WITH LOCAL TIME ZONE", FunctionModifier.TIME);
// $NON-NLS-1$
convertModifier.addTypeMapping("TIMESTAMP WITHOUT TIME ZONE", FunctionModifier.TIMESTAMP);
// $NON-NLS-1$
convertModifier.addTypeMapping("TIMESTAMP WITH TIME ZONE", FunctionModifier.TIMESTAMP);
// $NON-NLS-1$
convertModifier.addTypeMapping("TIMESTAMP WITH LOCAL TIME ZONE", FunctionModifier.TIMESTAMP);
registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("CHR"));
registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("LOWERCASE"));
registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("UPPERCASE"));
registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("CEIL"));
registerFunctionModifier(SourceSystemFunctions.NULLIF, new AliasModifier("NVL"));
registerFunctionModifier(SourceSystemFunctions.CURDATE, new Constant("CURRENT_DATE"));
registerFunctionModifier(SourceSystemFunctions.CURTIME, new Constant("CURRENT_TIME"));
registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("RANDOM"));
registerFunctionModifier("CURRENT_TIMESTAMP", new Constant());
registerFunctionModifier("CURRENT_USER", new Constant());
registerFunctionModifier("INITIAL_USER", new Constant());
registerFunctionModifier("LOCAL_TIME", new Constant());
registerFunctionModifier("LOCAL_TIMESTAMP", new Constant());
registerFunctionModifier("SESSION_USER", new Constant());
registerFunctionModifier("SYSTEM_USER", new Constant());
registerFunctionModifier("USER", new Constant());
// pushdown
addPushDownFunction(ACTIAN, "CHAREXTRACT", CHAR, STRING, INTEGER);
addPushDownFunction(ACTIAN, "SHIFT", STRING, STRING, INTEGER);
addPushDownFunction(ACTIAN, "SIZE", INTEGER, STRING);
addPushDownFunction(ACTIAN, "SOUNDEX", STRING, STRING);
addPushDownFunction(ACTIAN, "SQUEEZE", STRING, STRING);
addPushDownFunction(ACTIAN, "TRUNC", BIG_DECIMAL, BIG_DECIMAL, INTEGER);
addPushDownFunction(ACTIAN, "DAY", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "DAY", INTEGER, DATE);
addPushDownFunction(ACTIAN, "CURRENT_TIMESTAMP", TIMESTAMP);
addPushDownFunction(ACTIAN, "CURRENT_USER", STRING);
addPushDownFunction(ACTIAN, "INITIAL_USER", STRING);
addPushDownFunction(ACTIAN, "LOCAL_TIME", TIME);
addPushDownFunction(ACTIAN, "LOCAL_TIMESTAMP", TIMESTAMP);
addPushDownFunction(ACTIAN, "SESSION_USER", STRING);
addPushDownFunction(ACTIAN, "SYSTEM_USER", STRING);
addPushDownFunction(ACTIAN, "USER", STRING);
addPushDownFunction(ACTIAN, "ADD_MONTHS", TIMESTAMP, TIMESTAMP, INTEGER);
addPushDownFunction(ACTIAN, "DATE_FORMAT", STRING, TIMESTAMP, STRING);
addPushDownFunction(ACTIAN, "DATE_PART", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "DATE_TRUNC", TIMESTAMP, TIMESTAMP);
addPushDownFunction(ACTIAN, "DAY", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "DAYOFMONTH", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "DAYOFWEEK", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "DAYOFYEAR", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "FROM_UNIXTIME", TIMESTAMP, INTEGER);
addPushDownFunction(ACTIAN, "HOUR", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "LASTDAY", TIMESTAMP, TIMESTAMP);
addPushDownFunction(ACTIAN, "MICROSECOND", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "MILLISECOND", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "MINUTE", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "MONTH", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "MONTHS_BETWEEN", FLOAT, TIMESTAMP, DATE, DATE);
addPushDownFunction(ACTIAN, "MONTHS_BETWEEN", FLOAT, TIMESTAMP, TIMESTAMP, TIMESTAMP);
addPushDownFunction(ACTIAN, "NANOSECOND", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "QUATER", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "SECOND", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "WEEK", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "YEAR", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "YEAR_WEEK", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "UNIX_TIMESTAMP", INTEGER, TIMESTAMP);
addPushDownFunction(ACTIAN, "WEEK_ISO", INTEGER, TIMESTAMP);
}
use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.
the class BaseDB2ExecutionFactory method start.
@Override
public void start() throws TranslatorException {
super.start();
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce"));
registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier());
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("MOD", getLanguageFactory()));
// add in type conversion
ConvertModifier convertModifier = new ConvertModifier();
// $NON-NLS-1$
convertModifier.addTypeMapping("real", FunctionModifier.FLOAT);
// $NON-NLS-1$
convertModifier.addTypeMapping("numeric(31,0)", FunctionModifier.BIGINTEGER);
// $NON-NLS-1$
convertModifier.addTypeMapping("numeric(31,12)", FunctionModifier.BIGDECIMAL);
// $NON-NLS-1$
convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
// $NON-NLS-1$
convertModifier.addTypeMapping("blob", FunctionModifier.BLOB, FunctionModifier.OBJECT);
// $NON-NLS-1$
convertModifier.addTypeMapping("clob", FunctionModifier.CLOB, FunctionModifier.XML);
convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
// $NON-NLS-1$ //$NON-NLS-2$
return Arrays.asList("timestamp('1970-01-01', ", function.getParameters().get(0), ")");
}
});
convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
// $NON-NLS-1$ //$NON-NLS-2$
return Arrays.asList("timestamp(", function.getParameters().get(0), ", '00:00:00')");
}
});
// the next convert is not strictly necessary for db2, but it also works for derby
convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
// $NON-NLS-1$ //$NON-NLS-2$
return Arrays.asList("cast(double(", function.getParameters().get(0), ") as real)");
}
});
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("varchar"), FunctionModifier.STRING);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("smallint"), FunctionModifier.BYTE, FunctionModifier.SHORT);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("integer"), FunctionModifier.INTEGER);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("bigint"), FunctionModifier.LONG);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("double"), FunctionModifier.DOUBLE);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("date"), FunctionModifier.DATE);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("time"), FunctionModifier.TIME);
// $NON-NLS-1$
convertModifier.addTypeConversion(new NullHandlingFormatModifier("timestamp"), FunctionModifier.TIMESTAMP);
convertModifier.addNumericBooleanConversions();
registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
}
use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.
the class DB2ExecutionFactory method start.
@Override
public void start() throws TranslatorException {
super.start();
registerFunctionModifier(SourceSystemFunctions.TRIM, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
List<Expression> p = function.getParameters();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
return Arrays.asList("STRIP(", p.get(2), ", ", ((Literal) p.get(0)).getValue(), ", ", p.get(1), ")");
}
});
registerFunctionModifier(SourceSystemFunctions.WEEK, new AliasModifier(WEEK_ISO));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addPushDownFunction("db2", "substr", "string", TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.INTEGER, TypeFacility.RUNTIME_NAMES.INTEGER);
}
use of org.teiid.translator.jdbc.AliasModifier in project teiid by teiid.
the class H2ExecutionFactory method start.
@Override
public void start() throws TranslatorException {
super.start();
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.PARSETIMESTAMP, new AliasModifier("parsedatetime"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.FORMATTIMESTAMP, new AliasModifier("formatdatetime"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day_of_month"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new AliasModifier("day_of_week"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.WEEK, new AliasModifier("iso_week"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new AliasModifier("day_of_year"));
// $NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UNESCAPE, new AliasModifier("stringdecode"));
registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(SourceSystemFunctions.MOD, getLanguageFactory()));
// TODO: this behavior is configurable in h2 starting with 1.1.119
registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new AddDiffModifier(true, getLanguageFactory()));
registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new AddDiffModifier(false, getLanguageFactory()));
ConvertModifier convert = new ConvertModifier();
// $NON-NLS-1$
convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN);
// $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.LONG);
// $NON-NLS-1$
convert.addTypeMapping("real", FunctionModifier.FLOAT);
// $NON-NLS-1$
convert.addTypeMapping("double", FunctionModifier.DOUBLE);
// $NON-NLS-1$
convert.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL);
// $NON-NLS-1$
convert.addTypeMapping("decimal(38,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", FunctionModifier.STRING);
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
// $NON-NLS-1$ //$NON-NLS-2$
addPushDownFunction("h2", "timestampdiff", TypeFacility.RUNTIME_NAMES.INTEGER, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.TIMESTAMP, TypeFacility.RUNTIME_NAMES.TIMESTAMP);
}
Aggregations