use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testBooleanToFloatb.
@Test
public void testBooleanToFloatb() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("float", Float.class) }, Float.class);
// $NON-NLS-1$
helpGetString1(func, "cast(0 AS real)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testTimestampToDate.
@Test
public void testTimestampToDate() throws Exception {
Literal c = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(89, 2, 3, 7, 8, 12, 99999), Timestamp.class);
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { c, // $NON-NLS-1$
LANG_FACTORY.createLiteral("date", String.class) }, java.sql.Date.class);
// $NON-NLS-1$
helpGetString1(func, "cast(stuff(stuff(convert(varchar, CAST('1989-03-03 07:08:12.0' AS DATETIME), 102), 5, 1, '-'), 8, 1, '-') AS datetime)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testStringToTime.
/**
******************END of cast(date AS INPUT) *****************
*/
/**
******************Beginning of cast(time AS INPUT) *****************
*/
@Test
public void testStringToTime() throws Exception {
// $NON-NLS-1$
String timeStr = "12:08:07";
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(timeStr, String.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("time", String.class) }, java.sql.Time.class);
// $NON-NLS-1$
helpGetString1(func, "cast('12:08:07' AS datetime)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testStringToTimestamp.
/**
******************END of cast(time AS INPUT) *****************
*/
/**
******************Beginning of cast(timestamp AS INPUT) *****************
*/
@Test
public void testStringToTimestamp() throws Exception {
// $NON-NLS-1$
String timestampStr = "1989-07-09 12:08:07";
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(timestampStr, String.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("timestamp", String.class) }, java.sql.Timestamp.class);
// $NON-NLS-1$
helpGetString1(func, "cast('1989-07-09 12:08:07' AS datetime)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testBigIntegerToShort.
@Test
public void testBigIntegerToShort() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { // $NON-NLS-1$
LANG_FACTORY.createLiteral(new java.math.BigInteger("123"), java.math.BigInteger.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("short", Short.class) }, Short.class);
// $NON-NLS-1$
helpGetString1(func, "cast(123 AS smallint)");
}
Aggregations