Package org.teiid.query.sql.symbol

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


    assertEquals("Resolved string form was incorrect ", sql, outerQuery.toString()); //$NON-NLS-1$
   
    //make sure there is a convert function wrapping the criteria left expression
    Collection functions = FunctionCollectorVisitor.getFunctions(outerQuery, true);
    assertTrue(functions.size() == 1);
    Function function = (Function)functions.iterator().next();
    assertTrue(function.getName().equals(FunctionLibrary.CONVERT));
    Expression[] args = function.getArgs();
    assertSame(e2, args[0]);
    assertTrue(args[1] instanceof Constant);   
  }
View Full Code Here


        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();
   
    // Expected criteria
    CompareCriteria expected = new CompareCriteria();
    expected.setLeftExpression(e1);
    expected.setOperator(CompareCriteria.EQ);
View Full Code Here

    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();
   
    // Expected criteria
    CompareCriteria expected = new CompareCriteria();
    expected.setLeftExpression(conversion);
    expected.setOperator(CompareCriteria.EQ);
View Full Code Here

        ElementSymbol e1 = new ElementSymbol("pm3.g1.e4"); //$NON-NLS-1$
        e1.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
              
        // Expected right expression
        Constant e2 = new Constant(TimestampUtil.createDate(96, 0, 31), DataTypeManager.DefaultDataClasses.DATE);
        Function f1 = new Function("convert", new Expression[] { e2, new Constant(DataTypeManager.DefaultDataTypes.TIMESTAMP)}); //$NON-NLS-1$
        f1.makeImplicit();
              
        // Expected criteria
        CompareCriteria expected = new CompareCriteria();
        expected.setLeftExpression(e1);
        expected.setOperator(CompareCriteria.GT);
View Full Code Here

        //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();
        // Expected right expression
        Expression e1 = new Constant("bqt2", String.class); //$NON-NLS-1$
View Full Code Here

     * @since 4.2
     */
    private static boolean containsFunctionsThatCannotBePushed(Expression expression) {
        Iterator functions = FunctionCollectorVisitor.getFunctions(expression, true).iterator();
        while (functions.hasNext()) {
            Function function = (Function)functions.next();
            if (function.getFunctionDescriptor().getPushdown() == PushDown.CANNOT_PUSHDOWN) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

    // ################################## TEST HELPERS ################################

    // ################################## ACTUAL TESTS ################################

    public void testFunction1() {
        Function f1 = new Function("f1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        Function f2 = new Function("f1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        UnitTestUtil.helpTestEquivalence(0, f1, f2);       
    }   
View Full Code Here

        Function f2 = new Function("f1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        UnitTestUtil.helpTestEquivalence(0, f1, f2);       
    }   

    public void testFunction2() {
        Function f1 = new Function("f1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        Function f2 = new Function("F1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        UnitTestUtil.helpTestEquivalence(0, f1, f2);       
    }   
View Full Code Here

        Function f2 = new Function("F1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        UnitTestUtil.helpTestEquivalence(0, f1, f2);       
    }   

    public void testFunction3() {
        Function f1 = new Function("f1", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        Function f2 = new Function("f2", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        UnitTestUtil.helpTestEquivalence(1, f1, f2);       
    }
View Full Code Here

        Function f2 = new Function("f2", new Expression[] {new Constant("xyz")}); //$NON-NLS-1$ //$NON-NLS-2$
        UnitTestUtil.helpTestEquivalence(1, f1, f2);       
    }
   
    public void testFunction4() {
        Function f1 = new Function("f1", new Expression[] {null}); //$NON-NLS-1$
        Function f2 = new Function("f1", new Expression[] {null}); //$NON-NLS-1$
        UnitTestUtil.helpTestEquivalence(0, f1, f2);       
    }    
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.