use of org.teiid.language.Function in project teiid by teiid.
the class MonthOrDayNameFunctionModifier method translate.
@Override
public List<?> translate(Function function) {
List<Expression> args = function.getParameters();
Function func = // $NON-NLS-1$
langFactory.createFunction(// $NON-NLS-1$
"TO_CHAR", Arrays.asList(args.get(0), langFactory.createLiteral(format, TypeFacility.RUNTIME_TYPES.STRING)), TypeFacility.RUNTIME_TYPES.STRING);
// For some reason, these values have trailing spaces
Function trimFunc = langFactory.createFunction(SourceSystemFunctions.RTRIM, Arrays.asList(func), TypeFacility.RUNTIME_TYPES.STRING);
return Arrays.asList(trimFunc);
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSQLConversionVisitor method helpTestMod.
private void helpTestMod(Literal c, String format, String expectedStr) throws Exception {
Function func = LANG_FACTORY.createFunction(format, Arrays.asList(c), String.class);
PrestoDBExecutionFactory ef = new PrestoDBExecutionFactory();
ef.start();
SQLConversionVisitor sqlVisitor = ef.getSQLConversionVisitor();
sqlVisitor.append(func);
assertEquals(expectedStr, sqlVisitor.toString());
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestLeftOrRightFunctionModifier method helpTestMod.
public void helpTestMod(Literal c, Literal d, String target, String expectedStr) throws Exception {
Function func = LANG_FACTORY.createFunction(target, Arrays.asList(c, d), String.class);
OracleExecutionFactory trans = new OracleExecutionFactory();
trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
assertEquals(expectedStr, sqlVisitor.toString());
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestMonthOrDayNameFunctionModifier method helpTestMod.
public void helpTestMod(Literal c, String format, String expectedStr) throws Exception {
Function func = // "monthname" //$NON-NLS-1$
LANG_FACTORY.createFunction(// "monthname" //$NON-NLS-1$
format.toLowerCase() + "name", Arrays.asList(c), String.class);
OracleExecutionFactory trans = new OracleExecutionFactory();
trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
assertEquals(expectedStr, sqlVisitor.toString());
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestOracleConvertModifier method helpTest.
public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", Arrays.asList(srcExpression, LANG_FACTORY.createLiteral(tgtType, String.class)), TypeFacility.getDataTypeClass(tgtType));
assertEquals(// $NON-NLS-1$ //$NON-NLS-2$
"Error converting from " + srcExpression.getType() + " to " + tgtType, expectedExpression, helpGetString(func));
}
Aggregations