Examples of Literal


Examples of org.teiid.language.Literal

        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

Examples of org.teiid.language.Literal

    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

Examples of org.teiid.language.Literal

                   
                    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

Examples of org.teiid.language.Literal

        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

Examples of org.teiid.language.Literal

        helpTestMod(arg1, "Month", //$NON-NLS-1$
            "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Month'))"); //$NON-NLS-1$
    }

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

Examples of org.teiid.language.Literal

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

Examples of org.teiid.language.Literal

        helpTestMod(arg1, "Day"//$NON-NLS-1$
            "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.01'}, 'Day'))"); //$NON-NLS-1$
    }

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

Examples of org.teiid.language.Literal

    }
   
    @Test public void testVisitConvertFunctionOracleStyle() throws Exception {
        String expected = "convert(columnA, integer)"; //$NON-NLS-1$
       
        List<? extends Expression> params = Arrays.asList(new ColumnReference(null, "columnA", null, String.class), new Literal("integer", String.class));
        Function test = new Function("convert", params, Integer.class); //$NON-NLS-1$
       
        assertEquals(expected, getString(test));
    }
View Full Code Here

Examples of org.teiid.language.Literal

        registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
        registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
      @Override
      public List<?> translate(Function function) {
        function.setName(SourceSystemFunctions.TAN);
        return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
      }
    });       
        registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
      @Override
      public List<?> translate(Function function) {
View Full Code Here

Examples of org.teiid.language.Literal

        registerFunctionModifier(SourceSystemFunctions.ARRAY_LENGTH, new FunctionModifier() {
     
      @Override
      public List<?> translate(Function function) {
        if (function.getParameters().size() == 1) {
          function.getParameters().add(new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER));
        }
        return null;
      }
    });
               
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.