use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testBooleanToStringa.
/**
******************END of cast(timestamp AS INPUT) *****************
*/
/**
***************Beginning of cast(string AS input)*****************
*/
@Test
public void testBooleanToStringa() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("string", String.class) }, String.class);
// $NON-NLS-1$
helpGetString1(func, "CASE WHEN 1 = 0 THEN 'false' ELSE 'true' END");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testLongToShort.
@Test
public void testLongToShort() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Long(1231232341), Long.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("short", Short.class) }, Short.class);
// $NON-NLS-1$
helpGetString1(func, "cast(1231232341 AS smallint)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testStringToFloat.
/**
*************** End of cast(biginteger AS input)*****************
*/
/**
*************** Beginning of cast(float AS input) ***********
*/
@Test
public void testStringToFloat() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { // $NON-NLS-1$
LANG_FACTORY.createLiteral("123", String.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("float", Float.class) }, Float.class);
// $NON-NLS-1$
helpGetString1(func, "cast('123' AS real)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier 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", new Expression[] { srcExpression, LANG_FACTORY.createLiteral(tgtType, String.class) }, DataTypeManager.getDataTypeClass(tgtType));
assertEquals(// $NON-NLS-1$ //$NON-NLS-2$
"Error converting from " + DataTypeManager.getDataTypeName(srcExpression.getType()) + " to " + tgtType, expectedExpression, helpGetString(func));
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testTimeToTimestamp.
@Test
public void testTimeToTimestamp() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(TimestampUtil.createTime(12, 2, 3), java.sql.Time.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("timestamp", String.class) }, java.sql.Timestamp.class);
// $NON-NLS-1$
helpGetString1(func, "CAST('1970-01-01 12:02:03.0' AS DATETIME)");
}
Aggregations