Search in sources :

Example 71 with Function

use of org.teiid.language.Function in project teiid by teiid.

the class TestSybaseIQConvertModifier method testShortToInteger.

@Test
public void testShortToInteger() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { LANG_FACTORY.createLiteral(new Short((short) 1243), Short.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("integer", Integer.class) }, Integer.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(1243 AS int)");
}
Also used : BigInteger(java.math.BigInteger) Function(org.teiid.language.Function) Test(org.junit.Test)

Example 72 with Function

use of org.teiid.language.Function in project teiid by teiid.

the class TestSybaseIQConvertModifier method testBooleanToBigDecimala.

@Test
public void testBooleanToBigDecimala() 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("bigdecimal", java.math.BigDecimal.class) }, java.math.BigDecimal.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(1 AS numeric(38, 19))");
}
Also used : Function(org.teiid.language.Function) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 73 with Function

use of org.teiid.language.Function in project teiid by teiid.

the class TestSybaseIQConvertModifier method testFloatToByte.

@Test
public void testFloatToByte() 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("byte", Byte.class) }, Byte.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(123.0 AS smallint)");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Example 74 with Function

use of org.teiid.language.Function in project teiid by teiid.

the class TestSybaseIQConvertModifier method testBigDecimalToString.

@Test
public void testBigDecimalToString() throws Exception {
    // $NON-NLS-1$
    java.math.BigDecimal m = new java.math.BigDecimal("-123124534.3");
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { LANG_FACTORY.createLiteral(m, java.math.BigDecimal.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("string", String.class) }, String.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(-123124534.3 AS varchar(4000))");
}
Also used : BigDecimal(java.math.BigDecimal) Function(org.teiid.language.Function) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 75 with Function

use of org.teiid.language.Function in project teiid by teiid.

the class TestSybaseIQConvertModifier 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");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Aggregations

Function (org.teiid.language.Function)173 Test (org.junit.Test)127 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)16 Literal (org.teiid.language.Literal)15 BigDecimal (java.math.BigDecimal)14 List (java.util.List)13 Expression (org.teiid.language.Expression)13 AliasModifier (org.teiid.translator.jdbc.AliasModifier)12 FunctionModifier (org.teiid.translator.jdbc.FunctionModifier)12 SQLConversionVisitor (org.teiid.translator.jdbc.SQLConversionVisitor)9 LinkedList (java.util.LinkedList)3 ColumnReference (org.teiid.language.ColumnReference)3 Comparison (org.teiid.language.Comparison)3 SearchedCase (org.teiid.language.SearchedCase)3 EscapeSyntaxModifier (org.teiid.translator.jdbc.EscapeSyntaxModifier)3 ModFunctionModifier (org.teiid.translator.jdbc.ModFunctionModifier)3 ConcatFunctionModifier (org.teiid.translator.jdbc.oracle.ConcatFunctionModifier)3 Timestamp (java.sql.Timestamp)2 AggregateFunction (org.teiid.language.AggregateFunction)2