Package org.teiid.language

Examples of org.teiid.language.Literal


        helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
            "to_number(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'DDD'))"); //$NON-NLS-1$
    }

    public void test2() throws Exception {
        Literal arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
        helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
            "to_number(TO_CHAR({d '2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
    }
View Full Code Here


        helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
            "to_number(TO_CHAR({d '2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
    }
   
    public void test9() throws Exception {
        Literal arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 10000000), Timestamp.class);
        helpTestMod(arg1, SourceSystemFunctions.QUARTER,
            "to_number(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Q'))"); //$NON-NLS-1$
    }
View Full Code Here

        helpTestMod(arg1, SourceSystemFunctions.QUARTER,
            "to_number(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Q'))"); //$NON-NLS-1$
    }

    public void test10() throws Exception {
        Literal arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
        helpTestMod(arg1, SourceSystemFunctions.QUARTER,
            "to_number(TO_CHAR({d '2004-01-21'}, 'Q'))"); //$NON-NLS-1$
    }
View Full Code Here

       
        assertEquals("cast('2003-12-31' AS datetime)", helpGetString(func)); //$NON-NLS-1$
    }
   
    @Test public void testTimestampToDate() throws Exception {
        Literal c = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(89, 2, 3, 7, 8, 12, 99999), Timestamp.class);
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                c,
                LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
            java.sql.Date.class);
View Full Code Here

       
        helpGetString1(func,  "cast('12:08:07' AS datetime)")//$NON-NLS-1$
    }
   
    @Test public void testTimestampToTime() throws Exception {
        Literal c = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(89, 2, 3, 7, 8, 12, 99999), Timestamp.class);
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                c,
                LANG_FACTORY.createLiteral("time", String.class)}, //$NON-NLS-1$
            java.sql.Time.class);
View Full Code Here

        sqlVisitor.append(func)
        assertEquals(expectedStr, sqlVisitor.toString());
    }

    public void test1() throws Exception {
        Literal arg1 = LANG_FACTORY.createLiteral("1234214", String.class); //$NON-NLS-1$
        Literal count = LANG_FACTORY.createLiteral(new Integer(11), Integer.class);
        helpTestMod(arg1, count, "left", //$NON-NLS-1$
            "SUBSTR('1234214', 1, 11)"); //$NON-NLS-1$
    }
View Full Code Here

        helpTestMod(arg1, count, "left", //$NON-NLS-1$
            "SUBSTR('1234214', 1, 11)"); //$NON-NLS-1$
    }
   
    public void test2() throws Exception {
        Literal arg1 = LANG_FACTORY.createLiteral("1234214", String.class); //$NON-NLS-1$
        Literal count = LANG_FACTORY.createLiteral(new Integer(2), Integer.class);
        helpTestMod(arg1, count, "right", //$NON-NLS-1$
            "SUBSTR('1234214', (-1 * 2))"); //$NON-NLS-1$
    }
View Full Code Here

    public TestLog10FunctionModifier(String name) {
        super(name);
    }

    public void testModifier() {
        Literal arg = LANG_FACTORY.createLiteral(new Double(5.2), Double.class);
        Function func = LANG_FACTORY.createFunction("log10", Arrays.asList(arg), Double.class); //$NON-NLS-1$
       
        Log10FunctionModifier modifier = new Log10FunctionModifier(LANG_FACTORY);
        modifier.translate(func);
       
        assertEquals("log", func.getName()); //$NON-NLS-1$
        assertEquals(Double.class, func.getType());
       
        List<Expression> outArgs = func.getParameters();
        assertEquals(2, outArgs.size());
        assertEquals(arg, outArgs.get(1));
       
        assertTrue(outArgs.get(1) instanceof Literal);
        Literal newArg = (Literal) outArgs.get(0);
        assertEquals(Integer.class, newArg.getType());
        assertEquals(new Integer(10), newArg.getValue());
       
        assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(func));              //$NON-NLS-1$
    }
View Full Code Here

                   
                    IteratorValueSource<List<Object>> ivs = (IteratorValueSource)insert.getValueSource();
                    List<Object>[] values = new List[ivs.getColumnCount()];
                    for (int i = 0; i < ivs.getColumnCount(); i++) {
                      values[i] = new ArrayList<Object>();
                      Literal literal = new Literal(values[i], insert.getColumns().get(i).getType());
                      literal.setMultiValued(true);
                      translatedComm.getPreparedValues().add(literal);
                    }
                    Iterator<List<Object>> i = ivs.getIterator();
                    int maxBatchSize = this.executionFactory.getMaxPreparedInsertBatchSize();
                    while (i.hasNext()) {
                      int batchSize = 0;
                      while (i.hasNext() && batchSize++ < maxBatchSize) {
                        List<Object> next = i.next();
                        for (int j = 0; j < ivs.getColumnCount(); j++) {
                          values[j].add(next.get(j));
                          }
                      }
                      updateCount += executePreparedBatch(translatedComm, pstatement, batchSize);
                      for (int j = 0; j < ivs.getColumnCount(); j++) {
                        values[j].clear();
                        }
                    }
                    succeeded = true;
                    return new int[updateCount];
                  }
                }
             
                int rowCount = 1;
                for (int i = 0; i< translatedComm.getPreparedValues().size(); i++) {
                    Literal paramValue = (Literal)translatedComm.getPreparedValues().get(i);
                    if (paramValue.isMultiValued()) {
                      rowCount = ((List<?>)paramValue.getValue()).size();
                      break;
                    }
                }
                if (rowCount > 1) {
                    commitType = getAutoCommit(translatedComm);
View Full Code Here

        sqlVisitor.append(func)
        assertEquals(expectedStr, sqlVisitor.toString());
    }

    public void test1() throws Exception {
        Literal arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 10000000), Timestamp.class);
        helpTestMod(arg1, "Month", //$NON-NLS-1$
            "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Month'))"); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.language.Literal

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.