Package org.teiid.query.sql.symbol

Examples of org.teiid.query.sql.symbol.Function


       
        assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, function.getType());
    }
   
    @Test public void testResolveConvertReference() throws Exception {
        Function function = new Function("convert", new Expression[] {new Reference(0), new Constant(DataTypeManager.DefaultDataTypes.BOOLEAN)}); //$NON-NLS-1$
       
        ResolverVisitor.resolveLanguageObject(function, FakeMetadataFactory.example1Cached());
       
        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getType());
        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getArgs()[0].getType());
    }
View Full Code Here


        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getType());
        assertEquals(DataTypeManager.DefaultDataClasses.BOOLEAN, function.getArgs()[0].getType());
    }
   
    @Test public void testResolveAmbiguousFunction() throws Exception {
        Function function = new Function("LCASE", new Expression[] {new Reference(0)}); //$NON-NLS-1$
       
        try {
          ResolverVisitor.resolveLanguageObject(function, FakeMetadataFactory.example1Cached());
            fail("excpetion expected"); //$NON-NLS-1$
        } catch (QueryResolverException err) {
View Full Code Here

      helpResolveFunction(sql);
    }

  private Function helpResolveFunction(String sql) throws QueryParserException,
      QueryResolverException, TeiidComponentException {
    Function func = (Function)getExpression(sql);
      assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getType());
      return func;
  }
View Full Code Here

   * e1 is of type string, so 1 should be converted to string
   * @throws Exception
   */
    @Test public void testLookupTypeConversion() throws Exception {
      String sql = "lookup('pm1.g1', 'e2', 'e1', 1)"; //$NON-NLS-1$
      Function f = (Function)getExpression(sql);
      assertEquals(DataTypeManager.DefaultDataClasses.STRING, f.getArg(3).getType());
    }
View Full Code Here

    //second pass resolving for functions
    if (!(obj instanceof Function)) {
      return;
    }
    if (unresolvedFunctions != null) {
      Function f = (Function)obj;
      if (f.getFunctionDescriptor() != null) {
        return;
      }
          unresolvedFunctions.remove(obj);
      obj.acceptVisitor(this);
      QueryResolverException e = unresolvedFunctions.get(obj);
View Full Code Here

        ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
        e1.setType(String.class);       
        ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
        e2.setType(String.class);
       
        Function func = new Function("concat", new Expression[] { e1, e2 }); //$NON-NLS-1$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
        func.setFunctionDescriptor(desc);

        SingleElementSymbol[] elements = new SingleElementSymbol[] {
            e1, e2
        };
       
View Full Code Here

        ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
        e1.setType(String.class);       
        ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
        e2.setType(String.class);
       
        Function func = new Function("concat", new Expression[] { e2, e1 }); //$NON-NLS-1$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new Class[] { String.class, String.class } ); //$NON-NLS-1$
        func.setFunctionDescriptor(desc);

        SingleElementSymbol[] elements = new SingleElementSymbol[] {
            e1, e2
        };
       
View Full Code Here

        ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
        e1.setType(String.class);       
        ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
        e1.setType(Integer.class);       
       
        Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), e1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
        func.setFunctionDescriptor(desc);

        SingleElementSymbol[] elements = new SingleElementSymbol[] {
            e1, e2
        };
       
View Full Code Here

            assertEquals("Error Code:ERR.015.006.0058 Message:Unable to evaluate (<undefined>): Error Code:ERR.015.006.0058 Message:The command of this scalar subquery returned more than one value: <undefined>", e.getMessage()); //$NON-NLS-1$
        }
    }

    @Test public void testUser() throws Exception {
        Function func = new Function("user", new Expression[] {}); //$NON-NLS-1$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("user", new Class[] {} );         //$NON-NLS-1$
        func.setFunctionDescriptor(desc);

        FakeDataManager dataMgr = new FakeDataManager();
        CommandContext context = new CommandContext(new Long(1), null, null, null, 0);
        context.setUserName("logon")//$NON-NLS-1$
        assertEquals(context.getUserName(), new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList()) );      
View Full Code Here

     * and testsrc/config.xml. If the implementation is changed, please update/remove
     * these files.
     * @throws Exception
     */
    @Test public void testEnv() throws Exception {
        Function func = new Function("env", new Expression[] {}); //$NON-NLS-1$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("env", new Class[] {String.class} );         //$NON-NLS-1$
        func.setFunctionDescriptor(desc);
       
        FakeDataManager dataMgr = new FakeDataManager();
       
        Properties props = new Properties();
        props.setProperty("http_host", "testHostName"); //$NON-NLS-1$ //$NON-NLS-2$
        props.setProperty("http_port", "8000"); //$NON-NLS-1$ //$NON-NLS-2$
        CommandContext context = new CommandContext(new Long(1), null, null, null, null, 0, props, false);
       
        func.setArgs(new Expression[] {new Constant("http_host")}); //$NON-NLS-1$
        assertEquals("testHostName", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
              
        func.setArgs(new Expression[] {new Constant("http_port")}); //$NON-NLS-1$
        assertEquals("8000", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.symbol.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.