Examples of ExpressionSymbol


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

        Expression replacement = replaceExpression(obj.getSymbol());
       
        if (replacement instanceof SingleElementSymbol) {
            obj.setSymbol((SingleElementSymbol)replacement);
        } else {
            obj.setSymbol(new ExpressionSymbol(obj.getName(), replacement));
        }
    }
View Full Code Here

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

    Select select = new Select();
    select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$
    select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$

    OrderBy orderby = new OrderBy();
    orderby.addVariable(new ExpressionSymbol("expr", new Constant(1)), true); //$NON-NLS-1$

    Query query = new Query();
    query.setSelect(select);
    query.setFrom(from);
    query.setOrderBy(orderby);       
View Full Code Here

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

        String sql = "select a.x()"; //$NON-NLS-1$
       
        Query query = new Query();
        Select select = new Select();
        Function func1 = new Function("a.x", new Expression[] { }); //$NON-NLS-1$
        ExpressionSymbol exprSymbol = new ExpressionSymbol("expr", func1); //$NON-NLS-1$
        select.addSymbol(exprSymbol);       
        query.setSelect(select);
       
        helpTest(sql, "SELECT a.x()", query); //$NON-NLS-1$
    }
View Full Code Here

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

    @Test public void testIfElseWithoutBeginEnd() {
        String sql = "CREATE PROCEDURE BEGIN IF (x > 1) select 1; IF (x > 1) select 1; ELSE select 1; END"; //$NON-NLS-1$
        String expected = "CREATE PROCEDURE\nBEGIN\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nELSE\nBEGIN\nSELECT 1;\nEND\nEND"; //$NON-NLS-1$
       
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(new Object[] {new ExpressionSymbol("expr", new Constant(new Integer(1)))}))); //$NON-NLS-1$
        CommandStatement commandStmt = new CommandStatement(query);
        CompareCriteria criteria = new CompareCriteria(new ElementSymbol("x"), CompareCriteria.GT, new Constant(new Integer(1))); //$NON-NLS-1$
        Block block = new Block();
        block.addStatement(commandStmt);
        IfStatement ifStmt = new IfStatement(criteria, block);
View Full Code Here

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

   
    @Test public void testLOBTypes() throws Exception {
        Function convert = new Function("convert", new Expression[] {new Constant(null), new Constant("blob")}); //$NON-NLS-1$ //$NON-NLS-2$
        Function convert1 = new Function("convert", new Expression[] {new Constant(null), new Constant("clob")}); //$NON-NLS-1$ //$NON-NLS-2$
        Function convert2 = new Function("convert", new Expression[] {new Constant(null), new Constant("xml")}); //$NON-NLS-1$ //$NON-NLS-2$
        Select select = new Select(Arrays.asList(new Object[] {new ExpressionSymbol("expr", convert), new ExpressionSymbol("expr1", convert1), new ExpressionSymbol("expr2", convert2)})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        Query query = new Query();
        query.setSelect(select);
       
        helpTest("select convert(null, blob), convert(null, clob), convert(null, xml)", "SELECT convert(null, blob), convert(null, clob), convert(null, xml)", query); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

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

    }
   
    @Test public void testArrayAggWithIndexing() throws Exception {
        String sql = "SELECT (array_agg(1))[1]"; //$NON-NLS-1$
        AggregateSymbol as = new AggregateSymbol("foo", Reserved.ARRAY_AGG, false, new Constant(1));
        ExpressionSymbol expr = new ExpressionSymbol("expr", new Function("array_get", new Expression[] {as, new Constant(1)}));
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(expr)));
        helpTest(sql, "SELECT array_get(ARRAY_AGG(1), 1)", query);
    }
View Full Code Here

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

    }
   
    @Test public void testPositionalReference() throws Exception {
      String sql = "select $1";
      Query query = new Query();
      query.setSelect(new Select(Arrays.asList(new ExpressionSymbol("foo", new Reference(0)))));
        helpTest(sql, "SELECT ?", query);
    }
View Full Code Here

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

    GroupSymbol g = new GroupSymbol("g"); //$NON-NLS-1$
    From from = new From();
    from.addGroup(g);

    Function f = new Function("CONVERT", new Expression[] {new ElementSymbol("a", false), new Constant("string")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    ExpressionSymbol es = new ExpressionSymbol("expr", f); //$NON-NLS-1$
    Select select = new Select();
    select.addSymbol(es);

    Query query = new Query();
    query.setSelect(select);
View Full Code Here

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

    From from = new From();
    from.addGroup(g);

    Function f = new Function("CONVERT", new Expression[] {new ElementSymbol("a", false), new Constant("timestamp")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Function f2 = new Function("CONVERT", new Expression[] {f, new Constant("string")}); //$NON-NLS-1$ //$NON-NLS-2$
    ExpressionSymbol es = new ExpressionSymbol("expr", f2); //$NON-NLS-1$
    Select select = new Select();
    select.addSymbol(es);

    Query query = new Query();
    query.setSelect(select);
View Full Code Here

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

    from.addGroup(g);

    Function f = new Function("concat", new Expression[] {new ElementSymbol("a", false), new Constant("x")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Function f2 = new Function("length", new Expression[] {f}); //$NON-NLS-1$
    Function f3 = new Function("+", new Expression[] {new Constant(new Integer(5)), f2}); //$NON-NLS-1$
    ExpressionSymbol es = new ExpressionSymbol("expr", f3); //$NON-NLS-1$
    Select select = new Select();
    select.addSymbol(es);

    Query query = new Query();
    query.setSelect(select);
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.