use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseIQConvertModifier method testFloatToInteger.
@Test
public void testFloatToInteger() throws Exception {
Function func = // $NON-NLS-1$
LANG_FACTORY.createFunction(// $NON-NLS-1$
"convert", new Expression[] { LANG_FACTORY.createLiteral(new Float((float) 123.0), Float.class), // $NON-NLS-1$
LANG_FACTORY.createLiteral("integer", Integer.class) }, Integer.class);
// $NON-NLS-1$
helpGetString1(func, "cast(123.0 AS int)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseIQConvertModifier 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)");
}
use of org.teiid.language.Function in project teiid by teiid.
the class TestSybaseIQConvertModifier 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 TestSybaseIQConvertModifier method testDoubleToBoolean.
@Test
public void testDoubleToBoolean() 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("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 TestSybaseIQConvertModifier method testBigDecimalToBoolean.
@Test
public void testBigDecimalToBoolean() 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("1.0"), java.math.BigDecimal.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");
}
Aggregations