Search in sources :

Example 11 with UnaryFromClause

use of org.teiid.query.sql.lang.UnaryFromClause in project teiid by teiid.

the class TestQueryImpl method helpExampleFrom.

public static org.teiid.query.sql.lang.From helpExampleFrom() {
    List<UnaryFromClause> clauses = new ArrayList<UnaryFromClause>();
    // $NON-NLS-1$
    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1")));
    // $NON-NLS-1$ //$NON-NLS-2$
    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2")));
    // $NON-NLS-1$
    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3")));
    // $NON-NLS-1$
    clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4")));
    return new org.teiid.query.sql.lang.From(clauses);
}
Also used : UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) ArrayList(java.util.ArrayList)

Example 12 with UnaryFromClause

use of org.teiid.query.sql.lang.UnaryFromClause in project teiid by teiid.

the class TestLimitParsing method testSetQueryLimit.

@Test
public void testSetQueryLimit() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    SetQuery setQuery = new SetQuery(Operation.UNION, true, query, query);
    setQuery.setLimit(new Limit(new Reference(0), new Reference(1)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a union all Select * from a limit ?,?", "SELECT * FROM a UNION ALL SELECT * FROM a LIMIT ?, ?", setQuery);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) SetQuery(org.teiid.query.sql.lang.SetQuery) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 13 with UnaryFromClause

use of org.teiid.query.sql.lang.UnaryFromClause in project teiid by teiid.

the class TestLimitParsing method testLimit.

@Test
public void testLimit() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(null, new Constant(new Integer(100))));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit 100", "SELECT * FROM a LIMIT 100", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Constant(org.teiid.query.sql.symbol.Constant) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 14 with UnaryFromClause

use of org.teiid.query.sql.lang.UnaryFromClause in project teiid by teiid.

the class TestLimitParsing method testOffset.

@Test
public void testOffset() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(new Reference(0), null));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a offset ? rows", "SELECT * FROM a OFFSET ? ROWS", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 15 with UnaryFromClause

use of org.teiid.query.sql.lang.UnaryFromClause in project teiid by teiid.

the class TestLimitParsing method testLimitWithReferences1.

@Test
public void testLimitWithReferences1() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(new Reference(0), new Constant(new Integer(100))));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit ?,100", "SELECT * FROM a LIMIT ?, 100", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Constant(org.teiid.query.sql.symbol.Constant) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Aggregations

UnaryFromClause (org.teiid.query.sql.lang.UnaryFromClause)20 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)16 Query (org.teiid.query.sql.lang.Query)13 From (org.teiid.query.sql.lang.From)11 Select (org.teiid.query.sql.lang.Select)11 SetQuery (org.teiid.query.sql.lang.SetQuery)11 Test (org.junit.Test)10 Limit (org.teiid.query.sql.lang.Limit)10 MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)10 Constant (org.teiid.query.sql.symbol.Constant)8 Reference (org.teiid.query.sql.symbol.Reference)5 HashSet (java.util.HashSet)4 JoinPredicate (org.teiid.query.sql.lang.JoinPredicate)4 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)3 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)2 IOException (java.io.IOException)1 Clob (java.sql.Clob)1 SQLException (java.sql.SQLException)1