Search in sources :

Example 36 with Constant

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

the class TestSetCriteria method testNonHashableClone.

@Test
public void testNonHashableClone() {
    SetCriteria c1 = new SetCriteria();
    // $NON-NLS-1$
    c1.setExpression(new ElementSymbol("e1"));
    TreeSet vals = new TreeSet();
    vals.add(new Constant(BigDecimal.valueOf(1.1)));
    vals.add(new Constant(BigDecimal.valueOf(1.2)));
    c1.setValues(vals);
    c1.setAllConstants(true);
    SetCriteria c2 = (SetCriteria) c1.clone();
    assertTrue(c2.getValues() instanceof TreeSet);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TreeSet(java.util.TreeSet) Constant(org.teiid.query.sql.symbol.Constant) Test(org.junit.Test)

Example 37 with Constant

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

the class TestSetCriteria method sample2.

public static final SetCriteria sample2() {
    SetCriteria c1 = new SetCriteria();
    // $NON-NLS-1$
    c1.setExpression(new ElementSymbol("e2"));
    List vals = new ArrayList();
    // $NON-NLS-1$
    vals.add(new Constant("c"));
    // $NON-NLS-1$
    vals.add(new Constant("d"));
    c1.setValues(vals);
    return c1;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 38 with Constant

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

the class TestSubqueryFromClause method example1.

// ################################## HELPERS ################################
public static SubqueryFromClause example1() {
    Query query = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("a"));
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("b"));
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("m.g"));
    query.setFrom(from);
    CompareCriteria crit = new CompareCriteria();
    // $NON-NLS-1$
    crit.setLeftExpression(new ElementSymbol("a"));
    crit.setRightExpression(new Constant(new Integer(5)));
    crit.setOperator(CompareCriteria.EQ);
    query.setCriteria(crit);
    // $NON-NLS-1$
    return new SubqueryFromClause("temp", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) 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) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) SubqueryFromClause(org.teiid.query.sql.lang.SubqueryFromClause)

Example 39 with Constant

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

the class TestSubquerySetCriteria method example1.

public static SubquerySetCriteria example1() {
    Query query = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("a"));
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("b"));
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("m.g"));
    query.setFrom(from);
    CompareCriteria crit = new CompareCriteria();
    // $NON-NLS-1$
    crit.setLeftExpression(new ElementSymbol("a"));
    crit.setRightExpression(new Constant(new Integer(5)));
    crit.setOperator(CompareCriteria.EQ);
    query.setCriteria(crit);
    // $NON-NLS-1$
    return new SubquerySetCriteria(new ElementSymbol("temp"), query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) 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) SubquerySetCriteria(org.teiid.query.sql.lang.SubquerySetCriteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

Example 40 with Constant

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

the class TestSubquerySetCriteria method example3.

public static SubquerySetCriteria example3() {
    Query query = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("a"));
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("b"));
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("m.g"));
    query.setFrom(from);
    CompareCriteria crit = new CompareCriteria();
    // $NON-NLS-1$
    crit.setLeftExpression(new ElementSymbol("a"));
    crit.setRightExpression(new Constant(new Integer(5)));
    crit.setOperator(CompareCriteria.EQ);
    query.setCriteria(crit);
    // $NON-NLS-1$
    return new SubquerySetCriteria(new ElementSymbol("temp2"), query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) 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) SubquerySetCriteria(org.teiid.query.sql.lang.SubquerySetCriteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

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