Search in sources :

Example 56 with Function

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

the class TestSybaseIQConvertModifier method testBooleanToLonga.

@Test
public void testBooleanToLonga() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", // $NON-NLS-1$
    new Expression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), LANG_FACTORY.createLiteral("long", Long.class) }, Long.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(1 AS bigint)");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Example 57 with Function

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

the class TestSybaseIQConvertModifier method testStringToFloat.

/**
 *************** End of cast(biginteger AS input)*****************
 */
/**
 *************** Beginning of cast(float AS input) ***********
 */
@Test
public void testStringToFloat() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { // $NON-NLS-1$
    LANG_FACTORY.createLiteral("123", String.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("float", Float.class) }, Float.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast('123' AS real)");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Example 58 with Function

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

the class TestSybaseIQConvertModifier method testDateToTimestamp.

@Test
public void testDateToTimestamp() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { LANG_FACTORY.createLiteral(TimestampUtil.createDate(89, 2, 3), java.sql.Date.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("timestamp", String.class) }, java.sql.Timestamp.class);
    // $NON-NLS-1$
    helpGetString1(func, "cast(CAST('1989-03-03' AS DATE) AS timestamp)");
}
Also used : Function(org.teiid.language.Function) Test(org.junit.Test)

Example 59 with Function

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

the class TestSybaseIQConvertModifier 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)

Example 60 with Function

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

the class TestSybaseIQConvertModifier method testStringToBoolean.

/**
 *************** End of cast(char AS input)*****************
 */
/**
 *************** Beginning of cast(boolean AS input) ***********
 */
@Test
public void testStringToBoolean() throws Exception {
    Function func = // $NON-NLS-1$
    LANG_FACTORY.createFunction(// $NON-NLS-1$
    "convert", new Expression[] { // $NON-NLS-1$
    LANG_FACTORY.createLiteral("true", String.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral("boolean", Boolean.class) }, Boolean.class);
    // $NON-NLS-1$
    helpGetString1(func, "CASE WHEN 'true' IN ('false', '0') THEN 0 WHEN 'true' 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