Examples of findFunction()


Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        if (args.length == 2) {
          Function result = new Function(SourceSystemFunctions.IFNULL,
              new Expression[] {function.getArg(0), function.getArg(1) });
          //resolve the function
          FunctionDescriptor descriptor =
            funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { function.getType(), function.getType()  });
          result.setFunctionDescriptor(descriptor);
          result.setType(function.getType());
          function = result;
        }
        break;
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        for(int i=0; i<args.length; i++) {
          newArgs[i] = new Function(SourceSystemFunctions.IFNULL, new Expression[] {args[i], new Constant("")}); //$NON-NLS-1$
          newArgs[i].setType(args[i].getType());
          Assertion.assertTrue(args[i].getType() == DataTypeManager.DefaultDataClasses.STRING);
              FunctionDescriptor descriptor =
                funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
              newArgs[i].setFunctionDescriptor(descriptor);
        }
       
        Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
        concat.setType(DataTypeManager.DefaultDataClasses.STRING);
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        }
       
        Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
        concat.setType(DataTypeManager.DefaultDataClasses.STRING);
        FunctionDescriptor descriptor =
          funcLibrary.findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
        concat.setFunctionDescriptor(descriptor);
       
        List when = Arrays.asList(new Criteria[] {new CompoundCriteria(CompoundCriteria.AND, new IsNullCriteria(args[0]), new IsNullCriteria(args[1]))});
        Constant nullConstant = new Constant(null, DataTypeManager.DefaultDataClasses.STRING);
        List then = Arrays.asList(new Expression[] {nullConstant});
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        return rewriteExpressionDirect(caseExpr);
      }
      case 5: {
        if (function.getType() != DataTypeManager.DefaultDataClasses.TIMESTAMP) {
          FunctionDescriptor descriptor =
            funcLibrary.findFunction(SourceSystemFunctions.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
          function.setFunctionDescriptor(descriptor);
          Class<?> type = function.getType();
          function.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
          function.getArgs()[2] = ResolverUtil.getConversion(function.getArg(2), DataTypeManager.getDataTypeName(type), DataTypeManager.DefaultDataTypes.TIMESTAMP, false, funcLibrary);
          function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false, funcLibrary);
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        break;
      }
      case 6:
      case 7: {
        FunctionDescriptor descriptor =
          funcLibrary.findFunction(SourceSystemFunctions.PARSETIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
        function.setName(SourceSystemFunctions.PARSETIMESTAMP);
        function.setFunctionDescriptor(descriptor);
        Class<?> type = function.getType();
        function.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
        function = ResolverUtil.getConversion(function, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.getDataTypeName(type), false, funcLibrary);
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        break;
      }
      case 8:
      case 9: {
        FunctionDescriptor descriptor =
          funcLibrary.findFunction(SourceSystemFunctions.FORMATTIMESTAMP, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, DataTypeManager.DefaultDataClasses.STRING });
        function.setName(SourceSystemFunctions.FORMATTIMESTAMP);
        function.setFunctionDescriptor(descriptor);
        function.getArgs()[0] = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.TIMESTAMP, false, funcLibrary);
        break;
      }
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

        Class srcType = DataTypeManager.DefaultDataClasses.STRING;
        String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
        Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
       
    FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();                        
    FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });

    Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
    conversion.setType(DataTypeManager.getDataTypeClass(tgtTypeName));
    conversion.setFunctionDescriptor(fd);
    conversion.makeImplicit();
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

    Class srcType = DataTypeManager.DefaultDataClasses.STRING;
    String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
    Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
       
    FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();                       
    FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });

    Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
    conversion.setType(DataTypeManager.getDataTypeClass(tgtTypeName));
    conversion.setFunctionDescriptor(fd);
    conversion.makeImplicit();
View Full Code Here

Examples of org.teiid.query.function.FunctionLibrary.findFunction()

    @Test public void testUser() {
        //String sql = "select intkey from SmallA where user() = 'bqt2'";

        // Expected left expression
        FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();                         
        FunctionDescriptor fd = library.findFunction(FunctionLibrary.USER, new Class[] { });
        Function user = new Function(fd.getName(), new Expression[] {});
        user.setFunctionDescriptor(fd);

        // Expected criteria
        CompareCriteria expected = new CompareCriteria();
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.