Search in sources :

Example 46 with Function

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

the class TestSybaseConvertModifier method testShortToByte.

@Test
public void testShortToByte() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { LANG_FACTORY.createLiteral(new Short((short) 123), Short.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("byte", Byte.class) }, Byte.class);
    // $NON-NLS-1$
    helpGetString1(func, "123");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Example 47 with Function

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

the class TestSybaseIQConvertModifier method testBooleanToShorta.

@Test
public void testBooleanToShorta() 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("short", Short.class) }, Short.class);
    // $NON-NLS-1$
    helpGetString1(func, "1");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Example 48 with Function

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

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

Example 49 with Function

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

the class TestSybaseIQConvertModifier method testBigIntegerToInteger.

@Test
public void testBigIntegerToInteger() 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("integer", Integer.class) }, Integer.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(123 AS int)");
}
Also used : BigInteger(java.math.BigInteger) Function(org.teiid.language.Function) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 50 with Function

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

the class TestSybaseIQConvertModifier method testTimestampToTime.

@Test
public void testTimestampToTime() 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("time", String.class) }, java.sql.Time.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(CAST('1989-03-03 07:08:12.0' AS TIMESTAMP) AS time)");
}
Also used : Function(org.teiid.language.Function) Literal(org.teiid.language.Literal) 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