Package org.teiid.language

Examples of org.teiid.language.Function


       
        helpGetString1(func,  "cast(123.0 AS smallint)")//$NON-NLS-1$
    }
   
    @Test public void testDoubleToShort() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(new Double(1.0), Double.class),
                LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
            Short.class);
       
View Full Code Here


       
        helpGetString1(func,  "cast(1.0 AS smallint)")//$NON-NLS-1$
    }
   
    @Test public void testBigDecimalToShort() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral(new java.math.BigDecimal("12.3"), java.math.BigDecimal.class), //$NON-NLS-1$
                LANG_FACTORY.createLiteral("short",  Short.class)}, //$NON-NLS-1$
            Short.class);
       
View Full Code Here

     
      if (args.length > 0 ) param1 = args[0];
      if (args.length > 1 ) param2 = args[1];
      if (args.length > 2 ) param3 = args[2];
     
      Function func = null;
     
      if (param3 != null) {
        func = LANG_FACTORY.createFunction(SourceSystemFunctions.LOCATE,
                  Arrays.asList(param1, param2, param3), Integer.class);
      } else {
View Full Code Here

     */
    public void helpTestMod(final String modFunctionName, Expression[] args, String expectedStr) throws Exception {
      Expression param1 = args[0];
      Expression param2 = args[1];
     
      Function func = LANG_FACTORY.createFunction(modFunctionName,
            Arrays.asList(param1, param2), param1.getType());

      JDBCExecutionFactory trans = new JDBCExecutionFactory() {
      @Override
      public void start() throws TranslatorException {
View Full Code Here

       
        return sqlVisitor.toString();       
    }

    public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            Arrays.asList(
                srcExpression,
                LANG_FACTORY.createLiteral(tgtType, String.class)),
            TypeFacility.getDataTypeClass(tgtType));
       
View Full Code Here

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

    public void helpTestMod(Expression[] args, String expectedStr) throws Exception {
        Function func = LANG_FACTORY.createFunction("substring"//$NON-NLS-1$
            Arrays.asList(args), TypeFacility.RUNTIME_TYPES.STRING);
       
        OracleExecutionFactory trans = new OracleExecutionFactory();
        trans.start();
View Full Code Here

    }
   
    @Override
    public List<?> translate(Function function) {
        List<Expression> args = function.getParameters();
        Function func = null;
       
        if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
            func = langFactory.createFunction("SUBSTR"//$NON-NLS-1$
                Arrays.asList(
                    args.get(0),
                    langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER),
                    args.get(1)),
                    String.class);  
        } else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
            Function negIndex = langFactory.createFunction("*"//$NON-NLS-1$
                Arrays.asList(langFactory.createLiteral(Integer.valueOf(-1), TypeFacility.RUNTIME_TYPES.INTEGER), args.get(1)),
                Integer.class);
                           
            func = langFactory.createFunction("SUBSTR"//$NON-NLS-1$
                Arrays.asList(
View Full Code Here

      if (expr instanceof Literal) {
        Literal literal = (Literal)expr;
        return literal.getValue() != null;
      }
      if (expr instanceof Function) {
        Function function = (Function)expr;
        if (function.getName().equalsIgnoreCase("NVL") || function.getName().equalsIgnoreCase(SourceSystemFunctions.IFNULL)) { //$NON-NLS-1$
          return isNotNull(function.getParameters().get(1));
        }
      }
      return false;
    }
View Full Code Here

        TRANSLATOR.setUseBindVariables(false);
        TRANSLATOR.start();
    }
   
    public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"
            Arrays.asList( srcExpression,LANG_FACTORY.createLiteral(tgtType, String.class)),TypeFacility.getDataTypeClass(tgtType));
       
        assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
            expectedExpression, helpGetString(func));
    }   
View Full Code Here

      if (!l.isMultiValued()) {
        int value = (Integer)l.getValue();
        isNegative = value < 0;
      }
    }
    Expression maxLength = new Function(
        SourceSystemFunctions.SUBTRACT_OP,
        Arrays.asList(new Function(
                SourceSystemFunctions.LENGTH,
                Arrays.asList(function.getParameters().get(0)),
                TypeFacility.RUNTIME_TYPES.INTEGER),
              new Function(
                SourceSystemFunctions.SUBTRACT_OP,
                Arrays.asList(
                    function.getParameters().get(1),
                    new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)),
                  TypeFacility.RUNTIME_TYPES.INTEGER)),
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.