Package org.teiid.query.sql.lang

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


   
    @Test public void testOptionalFromClause2() {
        String sql = "SELECT * FROM t1, /*+ optional */ t2"; //$NON-NLS-1$
       
        Query query = new Query();
        Select select = new Select();
        select.addSymbol(new AllSymbol());
        query.setSelect(select);
        From from = new From();
        from.addGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        UnaryFromClause ufc = new UnaryFromClause();
        ufc.setGroup(new GroupSymbol("t2")); //$NON-NLS-1$
View Full Code Here


    @Test public void testOptionalFromClause3() {
        String sql = "SELECT * FROM /*+ optional */ t1 AS a, t2"; //$NON-NLS-1$
       
        Query query = new Query();
        Select select = new Select();
        select.addSymbol(new AllSymbol());
        query.setSelect(select);
        From from = new From();
        UnaryFromClause ufc = new UnaryFromClause();
        ufc.setGroup(new GroupSymbol("a", "t1")); //$NON-NLS-1$ //$NON-NLS-2$
        ufc.setOptional(true);
View Full Code Here

   
    @Test public void testOptionalFromClause4() {
        String sql = "SELECT * FROM t1, /*+ optional */ t2 as a"; //$NON-NLS-1$
       
        Query query = new Query();
        Select select = new Select();
        select.addSymbol(new AllSymbol());
        query.setSelect(select);
        From from = new From();
        from.addGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        UnaryFromClause ufc = new UnaryFromClause();
        ufc.setGroup(new GroupSymbol("a", "t2")); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

   
    @Test public void testOptionalFromClause5() {
        String sql = "SELECT * FROM t1, /*+ optional */ (select * from t1, t2) as x"; //$NON-NLS-1$
       
        Query query = new Query();
        Select select = new Select();
        select.addSymbol(new AllSymbol());
        query.setSelect(select);
        From from = new From();
       
        Query query2 = new Query();
        select = new Select();
        select.addSymbol(new AllSymbol());
        query2.setSelect(select);
        From from2 = new From();
        from2.addGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        from2.addGroup(new GroupSymbol("t2")); //$NON-NLS-1$
        query2.setFrom(from2);  
View Full Code Here

   
    @Test public void testOptionalFromClause6() {
        String sql = "SELECT * FROM t1 INNER JOIN /*+ optional */ (select a from t1, t2) AS x ON t1.a=x.a"; //$NON-NLS-1$
       
        Query query = new Query();
        Select select = new Select();
        select.addSymbol(new AllSymbol());
        query.setSelect(select);
        From from = new From();
       
        Query query2 = new Query();
        select = new Select();
        select.addSymbol(new ElementSymbol("a"));//$NON-NLS-1$
        From from2 = new From();
        from2.addGroup(new GroupSymbol("t1")); //$NON-NLS-1$
        from2.addGroup(new GroupSymbol("t2")); //$NON-NLS-1$
        query2.setSelect(select);
        query2.setFrom(from2);  
View Full Code Here

      assertEquals("Group ID does not match: ", groupIDs[i].toUpperCase(), matchString.toUpperCase()); //$NON-NLS-1$
    }
  }
 
  private void helpCheckSelect(Query query, String[] elementNames) {
    Select select = query.getSelect();
    List elements = select.getSymbols();
    assertEquals("Wrong number of select symbols: ", elementNames.length, elements.size()); //$NON-NLS-1$

    for(int i=0; i<elements.size(); i++) {
      SelectSymbol symbol = (SelectSymbol) elements.get(i);
      assertEquals("Element name does not match: ", elementNames[i].toUpperCase(), symbol.getName().toUpperCase()); //$NON-NLS-1$
View Full Code Here

    @Test public void testSubQueryINClause1(){
    //select e1 from pm1.g1 where e2 in (select e2 from pm4.g1)

    //sub command
    Select innerSelect = new Select();
    ElementSymbol e2inner = new ElementSymbol("e2"); //$NON-NLS-1$
    innerSelect.addSymbol(e2inner);
    From innerFrom = new From();
    GroupSymbol pm4g1 = new GroupSymbol("pm4.g1"); //$NON-NLS-1$
    innerFrom.addGroup(pm4g1);
    Query innerQuery = new Query();
    innerQuery.setSelect(innerSelect);
    innerQuery.setFrom(innerFrom);
   
    //outer command
    Select outerSelect = new Select();
    ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
      outerSelect.addSymbol(e1);
    From outerFrom = new From();
      GroupSymbol pm1g1 = new GroupSymbol("pm1.g1"); //$NON-NLS-1$
    outerFrom.addGroup(pm1g1);
      ElementSymbol e2outer = new ElementSymbol("e2"); //$NON-NLS-1$
    SubquerySetCriteria crit = new SubquerySetCriteria(e2outer, innerQuery);
View Full Code Here

   */
  @Test public void testSubQueryINClauseImplicitConversion(){
    //select e1 from pm1.g1 where e2 in (select e1 from pm4.g1)
 
    //sub command
    Select innerSelect = new Select();
    ElementSymbol e1inner = new ElementSymbol("e1"); //$NON-NLS-1$
    innerSelect.addSymbol(e1inner);
    From innerFrom = new From();
    GroupSymbol pm4g1 = new GroupSymbol("pm4.g1"); //$NON-NLS-1$
    innerFrom.addGroup(pm4g1);
    Query innerQuery = new Query();
    innerQuery.setSelect(innerSelect);
    innerQuery.setFrom(innerFrom);
   
    //outer command
    Select outerSelect = new Select();
    ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
    outerSelect.addSymbol(e1);
    From outerFrom = new From();
    GroupSymbol pm1g1 = new GroupSymbol("pm1.g1"); //$NON-NLS-1$
    outerFrom.addGroup(pm1g1);
    ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
    SubquerySetCriteria crit = new SubquerySetCriteria(e2, innerQuery);
View Full Code Here

   */
  @Test public void testSubQueryINClauseNoConversionFails(){
    //select e1 from pm1.g1 where e1 in (select e2 from pm4.g1)

    //sub command
    Select innerSelect = new Select();
    ElementSymbol e2inner = new ElementSymbol("e2"); //$NON-NLS-1$
    innerSelect.addSymbol(e2inner);
    From innerFrom = new From();
    GroupSymbol pm4g1 = new GroupSymbol("pm4.g1"); //$NON-NLS-1$
    innerFrom.addGroup(pm4g1);
    Query innerQuery = new Query();
    innerQuery.setSelect(innerSelect);
    innerQuery.setFrom(innerFrom);

    //outer command
    Select outerSelect = new Select();
    ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
    outerSelect.addSymbol(e1);
    From outerFrom = new From();
    GroupSymbol pm1g1 = new GroupSymbol("pm1.g1"); //$NON-NLS-1$
    outerFrom.addGroup(pm1g1);
    SubquerySetCriteria crit = new SubquerySetCriteria(e1, innerQuery);
    Query outerQuery = new Query();
View Full Code Here

    private Query createTestQuery(String group) {
        GroupSymbol g = new GroupSymbol(group);
        From from = new From();
        from.addGroup(g);

        Select select = new Select();
        select.addSymbol(new AllSymbol());
       
        Query query1 = new Query();
        query1.setSelect(select);
        query1.setFrom(from);
        return query1;
View Full Code Here

TOP

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

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.