Search in sources :

Example 91 with Constant

use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.

the class TestArrayProcessing method testArrayEquivalence.

@Test
public void testArrayEquivalence() throws Exception {
    Array a1 = new Array(new ArrayList<Expression>());
    UnitTestUtil.helpTestEquivalence(0, a1, a1);
    Array a2 = new Array(Arrays.asList((Expression) new Constant(1)));
    UnitTestUtil.helpTestEquivalence(1, a1, a2);
}
Also used : Array(org.teiid.query.sql.symbol.Array) Expression(org.teiid.query.sql.symbol.Expression) Constant(org.teiid.query.sql.symbol.Constant) Test(org.junit.Test)

Example 92 with Constant

use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.

the class TestRuleValidateWhereAll method testHasNoCriteria2.

public void testHasNoCriteria2() {
    Query query = new Query();
    // $NON-NLS-1$ //$NON-NLS-2$
    CompareCriteria crit = new CompareCriteria(new Constant("a"), CompareCriteria.EQ, new Constant("b"));
    query.setCriteria(crit);
    // $NON-NLS-1$
    assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(query));
}
Also used : Query(org.teiid.query.sql.lang.Query) Constant(org.teiid.query.sql.symbol.Constant) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

Example 93 with Constant

use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.

the class TestLimitParsing method testLimitWithOffset.

@Test
public void testLimitWithOffset() {
    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 Constant(new Integer(50)), new Constant(new Integer(100))));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit 50,100", "SELECT * FROM a LIMIT 50, 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 94 with Constant

use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.

the class TestLimitParsing method testLimitWithReferences2.

@Test
public void testLimitWithReferences2() {
    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 Constant(new Integer(50)), new Reference(0)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit 50,?", "SELECT * FROM a LIMIT 50, ?", 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) 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 95 with Constant

use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.

the class TestLimitParsing method testFetchFirstRow.

@Test
public void testFetchFirstRow() {
    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(1)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a fetch first row only", "SELECT * FROM a LIMIT 1", 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)

Aggregations

Constant (org.teiid.query.sql.symbol.Constant)203 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)94 Test (org.junit.Test)88 ArrayList (java.util.ArrayList)61 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)48 List (java.util.List)38 Expression (org.teiid.query.sql.symbol.Expression)38 Function (org.teiid.query.sql.symbol.Function)31 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)25 Query (org.teiid.query.sql.lang.Query)22 Select (org.teiid.query.sql.lang.Select)15 Reference (org.teiid.query.sql.symbol.Reference)14 From (org.teiid.query.sql.lang.From)12 HashMap (java.util.HashMap)11 FunctionDescriptor (org.teiid.query.function.FunctionDescriptor)11 Criteria (org.teiid.query.sql.lang.Criteria)11 SetQuery (org.teiid.query.sql.lang.SetQuery)11 LinkedList (java.util.LinkedList)10 Limit (org.teiid.query.sql.lang.Limit)10 StoredProcedure (org.teiid.query.sql.lang.StoredProcedure)9