Package org.teiid.language

Examples of org.teiid.language.Function


        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 'false' ELSE 'true' END")//$NON-NLS-1$
    }
   
    @Test public void testTimestampToString() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(ts, Timestamp.class),
                LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
            String.class);
View Full Code Here


        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)")//$NON-NLS-1$
    }
   
    @Test public void testDateToString() throws Exception {
        java.sql.Date d = TimestampUtil.createDate(103, 10, 1);
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(d, java.sql.Date.class),
                LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
            String.class);
       
View Full Code Here

        helpGetString1(func,  "stuff(stuff(convert(varchar, CAST('2003-11-01' AS DATE), 102), 5, 1, '-'), 8, 1, '-')")//$NON-NLS-1$
    }
   
    @Test public void testTimeToString() throws Exception {
        java.sql.Time t = TimestampUtil.createTime(3, 10, 1);
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(t, java.sql.Time.class),
                LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
            String.class);
       
View Full Code Here

        helpGetString1(func,  "convert(varchar, CAST('1970-01-01 03:10:01.0' AS DATETIME), 8)")//$NON-NLS-1$
    }   
   
    @Test public void testBigDecimalToString() throws Exception {
        java.math.BigDecimal m = new java.math.BigDecimal("-123124534.3"); //$NON-NLS-1$
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(m, java.math.BigDecimal.class),
                LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
            String.class);
       
View Full Code Here

    }
    /***************** End of cast(string AS input)******************/
   
    /***************** Beginning of cast(char AS input) ************/
    @Test public void testStringToChar() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral("12", String.class), //$NON-NLS-1$
                LANG_FACTORY.createLiteral("char", Character.class)}, //$NON-NLS-1$
        Character.class);
       
View Full Code Here

    }    
    /***************** End of cast(char AS input)******************/
    
    /***************** Beginning of cast(boolean AS input) ************/
    @Test public void testStringToBoolean() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral("true", String.class)//$NON-NLS-1$
                LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
            Boolean.class);
       
View Full Code Here

       
        helpGetString1(func,  "CASE WHEN 'true' IN ('false', '0') THEN 0 WHEN 'true' IS NOT NULL THEN 1 END")//$NON-NLS-1$
    }
   
    @Test public void testByteToBoolean() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class)
                LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
            Boolean.class);
       
View Full Code Here

       
        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END")//$NON-NLS-1$
    }
   
    @Test public void testShortToBoolean() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(new Short((short) 0), Short.class)
                LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
            Boolean.class);
       
View Full Code Here

       
        helpGetString1(func,  "CASE WHEN 0 = 0 THEN 0 WHEN 0 IS NOT NULL THEN 1 END")//$NON-NLS-1$
    }
   
    @Test public void testIntegerToBoolean() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(new Integer(1), Integer.class)
                LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
            Boolean.class);
       
View Full Code Here

       
        helpGetString1(func,  "CASE WHEN 1 = 0 THEN 0 WHEN 1 IS NOT NULL THEN 1 END")//$NON-NLS-1$
    }
   
    @Test public void testLongToBoolean() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(new Long(1), Long.class)
                LANG_FACTORY.createLiteral("boolean", Boolean.class)}, //$NON-NLS-1$
            Boolean.class);
       
View Full Code Here

TOP

Related Classes of org.teiid.language.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.