Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.Query


    @Test public void testOrderByUnrelated2() {
        helpResolveException("SELECT max(e2) FROM pm1.g1 group by e1 ORDER BY e4"); //$NON-NLS-1$
    }
   
    @Test public void testOrderByExpression() {
      Query query = (Query)helpResolve("select pm1.g1.e1 from pm1.g1 order by e2 || e3 "); //$NON-NLS-1$
      assertEquals(-1, query.getOrderBy().getExpressionPosition(0));
    }
View Full Code Here


      Query query = (Query)helpResolve("select pm1.g1.e1 from pm1.g1 order by e2 || e3 "); //$NON-NLS-1$
      assertEquals(-1, query.getOrderBy().getExpressionPosition(0));
    }
   
    @Test public void testOrderByExpression1() {
      Query query = (Query)helpResolve("select pm1.g1.e1 || e2 from pm1.g1 order by pm1.g1.e1 || e2 "); //$NON-NLS-1$
      assertEquals(0, query.getOrderBy().getExpressionPosition(0));
    }
View Full Code Here

    helpResolveUpdateProcedure(procedure, userUpdateStr);
    }
   
    //return should be first, then out
    @Test public void testParamOrder() {
        Query resolvedQuery = (Query)helpResolve("SELECT * FROM (exec pm4.spRetOut()) as a", RealMetadataFactory.exampleBQTCached()); //$NON-NLS-1$
       
        assertEquals("a.ret", resolvedQuery.getProjectedSymbols().get(0).getName());
    }
View Full Code Here

        select.addSymbol(expr);

        Reference ref1 = new Reference(1);
        Criteria crit = new MatchCriteria(new ElementSymbol("b"), ref1); //$NON-NLS-1$

        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
        query.setCriteria(crit);
        helpTest("SELECT ? from db.g where b LIKE ?"//$NON-NLS-1$
                 "SELECT ? FROM db.g WHERE b LIKE ?"//$NON-NLS-1$
                 query);       
    }
View Full Code Here

        Select select = new Select();
        ElementSymbol symbol = new ElementSymbol("c"); //$NON-NLS-1$
        select.addSymbol(symbol);
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
       
        SubqueryFromClause sfc = new SubqueryFromClause("y", query); //$NON-NLS-1$
        From from2 = new From();
        from2.addClause(sfc);
       
        Select select2 = new Select();
        select2.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
        select2.addSymbol(new ElementSymbol("b")); //$NON-NLS-1$
       
        Query query2 = new Query();
        query2.setSelect(select2);
        query2.setFrom(from2);
       
        helpTest("SELECT a, b FROM (SELECT c FROM m.g) AS y"//$NON-NLS-1$
                 "SELECT a, b FROM (SELECT c FROM m.g) AS y"//$NON-NLS-1$
                 query2);            
    }
View Full Code Here

        Select select = new Select();
        ElementSymbol symbol = new ElementSymbol("c"); //$NON-NLS-1$
        select.addSymbol(symbol);
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
       
        SubqueryFromClause sfc = new SubqueryFromClause("y", query); //$NON-NLS-1$
        From from2 = new From();
        from2.addClause(sfc);
       
        Select select2 = new Select();
        select2.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
        select2.addSymbol(new ElementSymbol("b")); //$NON-NLS-1$
       
        Query query2 = new Query();
        query2.setSelect(select2);
        query2.setFrom(from2);
       
        helpTest("SELECT a, b FROM ((SELECT c FROM m.g)) AS y"//$NON-NLS-1$
                 "SELECT a, b FROM (SELECT c FROM m.g) AS y"//$NON-NLS-1$
                 query2);            
    }   
View Full Code Here

        Select select = new Select();
        ElementSymbol symbol = new ElementSymbol("c"); //$NON-NLS-1$
        select.addSymbol(symbol);
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
       
        UnaryFromClause ufc = new UnaryFromClause(new GroupSymbol("m.g1")); //$NON-NLS-1$
        SubqueryFromClause sfc = new SubqueryFromClause("y", query); //$NON-NLS-1$
        CompareCriteria join = new CompareCriteria(new ElementSymbol("m.g1.a"), CompareCriteria.EQ, new ElementSymbol("y.c")); //$NON-NLS-1$ //$NON-NLS-2$
        List crits = new ArrayList();
        crits.add(join);
        JoinPredicate jp = new JoinPredicate(ufc, sfc, JoinType.JOIN_INNER, crits);
        From from2 = new From();
        from2.addClause(jp);
                       
        Select select2 = new Select();
        select2.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
        select2.addSymbol(new ElementSymbol("b")); //$NON-NLS-1$
       
        Query query2 = new Query();
        query2.setSelect(select2);
        query2.setFrom(from2);
       
        helpTest("SELECT a, b FROM m.g1 JOIN (SELECT c FROM m.g2) AS y ON m.g1.a = y.c"//$NON-NLS-1$
                 "SELECT a, b FROM m.g1 INNER JOIN (SELECT c FROM m.g2) AS y ON m.g1.a = y.c"//$NON-NLS-1$
                 query2);            
    }
View Full Code Here

        from.addClause(sfc);
       
        Select select = new Select();
        select.addSymbol(new ElementSymbol("x.a")); //$NON-NLS-1$
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
      helpTest("SELECT X.A FROM (exec proc1()) AS X", "SELECT X.A FROM (EXEC proc1()) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

        from.addClause(sfc);
       
        Select select = new Select();
        select.addSymbol(new ElementSymbol("x.a")); //$NON-NLS-1$
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
      helpTest("SELECT X.A FROM (exec proc1('param1')) AS X", "SELECT X.A FROM (EXEC proc1('param1')) AS X", query); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

        from.addClause(sfc);
       
        Select select = new Select();
        select.addSymbol(new ElementSymbol("x.a")); //$NON-NLS-1$
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
        helpTest("exec proc1('param1')", "EXEC proc1('param1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
    }   
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Query

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.