Search in sources :

Example 31 with Function

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

the class TestSybaseConvertModifier 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 32 with Function

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

the class TestSybaseConvertModifier method testStringToBigInteger.

/**
 *************** End of cast(long AS input)*****************
 */
/**
 *************** Beginning of cast(biginteger AS input) ***********
 */
@Test
public void testStringToBigInteger() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { // $NON-NLS-1$
    LANG_FACTORY.createLiteral("12323143241414", String.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("biginteger", java.math.BigInteger.class) }, java.math.BigInteger.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast('12323143241414' AS numeric(38, 0))");
}
Also used : Function(org.teiid.language.Function) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 33 with Function

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

the class TestSybaseConvertModifier method testBooleanToBytea.

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

Example 34 with Function

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

the class TestSybaseConvertModifier method testTimestampToString.

@Test
public void testTimestampToString() throws Exception {
    Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { LANG_FACTORY.createLiteral(ts, Timestamp.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 12:05:02.0' AS DATETIME), 102), 5, 1, '-'), 8, 1, '-')+convert(varchar, CAST('2003-11-01 12:05:02.0' AS DATETIME), 8)");
}
Also used : Function(org.teiid.language.Function) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Example 35 with Function

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

the class TestSybaseConvertModifier method testLongToByte.

@Test
public void testLongToByte() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { LANG_FACTORY.createLiteral(new Long(1231232341), Long.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("byte", Byte.class) }, Byte.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(1231232341 AS smallint)");
}
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