use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testTimeToString.
@Test
public void testTimeToString() throws Exception {
java.sql.Time t = TimestampUtil.createTime(3, 10, 1);
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(t, java.sql.Time.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("string", String.class) }, String.class);
// $NON-NLS-1$
helpGetString1(func, "convert(varchar, CAST('1970-01-01 03:10:01.0' AS DATETIME), 8)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testStringToShort.
/**
*************** End of cast(byte AS input)*****************
*/
/**
***************Beginning of cast(short AS input)***********
*/
@Test
public void testStringToShort() 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("short", Short.class) }, Short.class);
// $NON-NLS-1$
helpGetString1(func, "cast('123' AS smallint)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testFloatToBoolean.
@Test
public void testFloatToBoolean() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Float((float) 1.0), Float.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("boolean", Boolean.class) }, Boolean.class);
// $NON-NLS-1$
helpGetString1(func, "CASE WHEN 1.0 = 0 THEN 0 WHEN 1.0 IS NOT NULL THEN 1 END");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testStringToByte.
/**
*************** End of cast(boolean AS input)*****************
*/
/**
*************** Beginning of cast(byte AS input) ***********
*/
@Test
public void testStringToByte() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { // $NON-NLS-1$
LANG_FACTORY.createLiteral("12", String.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("byte", Byte.class) }, Byte.class);
// $NON-NLS-1$
helpGetString1(func, "cast('12' AS smallint)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testShortToBoolean.
@Test
public void testShortToBoolean() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Short((short) 0), Short.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("boolean", Boolean.class) }, Boolean.class);
// $NON-NLS-1$
helpGetString1(func, "CASE WHEN 0 = 0 THEN 0 WHEN 0 IS NOT NULL THEN 1 END");
}
Aggregations