use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testDateToString.
@Test
public void testDateToString() throws Exception {
java.sql.Date d = TimestampUtil.createDate(103, 10, 1);
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(d, java.sql.Date.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("string", String.class) }, String.class);
// $NON-NLS-1$
helpGetString1(func, "stuff(stuff(convert(varchar, CAST('2003-11-01' AS DATE), 102), 5, 1, '-'), 8, 1, '-')");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testBigDecimalToByte.
@Test
public void testBigDecimalToByte() 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.BigDecimal("12.3"), java.math.BigDecimal.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("byte", Byte.class) }, Byte.class);
// $NON-NLS-1$
helpGetString1(func, "cast(12.3 AS smallint)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testIntegerToBoolean.
@Test
public void testIntegerToBoolean() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Integer(1), Integer.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("boolean", Boolean.class) }, Boolean.class);
// $NON-NLS-1$
helpGetString1(func, "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testDoubleToInteger.
@Test
public void testDoubleToInteger() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Double(1.0), Double.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("integer", Integer.class) }, Integer.class);
// $NON-NLS-1$
helpGetString1(func, "cast(1.0 AS int)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseConvertModifier method testIntegerToByte.
@Test
public void testIntegerToByte() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Integer(1232321), Integer.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("byte", Byte.class) }, Byte.class);
// $NON-NLS-1$
helpGetString1(func, "cast(1232321 AS smallint)");
}
Aggregations