Search in sources :

Example 46 with Constant

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

the class TestDynamicCommand method testClone2.

public void testClone2() {
    List symbols = new ArrayList();
    // $NON-NLS-1$
    ElementSymbol a1 = new ElementSymbol("a1");
    a1.setType(DataTypeManager.DefaultDataClasses.STRING);
    symbols.add(a1);
    // $NON-NLS-1$
    Expression sql = new Constant("SELECT * FROM g");
    SetClauseList using = new SetClauseList();
    using.addClause(a1, a1);
    // $NON-NLS-1$
    DynamicCommand sqlCmd = new DynamicCommand(sql, symbols, new GroupSymbol("#g"), using);
    UnitTestUtil.helpTestEquivalence(0, sqlCmd, sqlCmd.clone());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) DynamicCommand(org.teiid.query.sql.lang.DynamicCommand) Expression(org.teiid.query.sql.symbol.Expression) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) List(java.util.List) SetClauseList(org.teiid.query.sql.lang.SetClauseList) ArrayList(java.util.ArrayList) SetClauseList(org.teiid.query.sql.lang.SetClauseList)

Example 47 with Constant

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

the class TestLimit method testGetOffset.

public void testGetOffset() {
    Limit limit = new Limit(new Constant(new Integer(50)), new Constant(new Integer(100)));
    assertEquals(new Constant(new Integer(50)), limit.getOffset());
    // Idempotent
    assertEquals(new Constant(new Integer(50)), limit.getOffset());
}
Also used : Constant(org.teiid.query.sql.symbol.Constant)

Example 48 with Constant

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

the class TestLimit method testGetRowLimit.

public void testGetRowLimit() {
    Limit limit = new Limit(new Constant(new Integer(10)), new Constant(new Integer(30)));
    assertEquals(new Constant(new Integer(30)), limit.getRowLimit());
    assertEquals(new Constant(new Integer(30)), limit.getRowLimit());
}
Also used : Constant(org.teiid.query.sql.symbol.Constant)

Example 49 with Constant

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

the class TestLimit method testToString.

public void testToString() {
    // $NON-NLS-1$
    assertEquals("LIMIT 50", new Limit(null, new Constant(new Integer(50))).toString());
    // $NON-NLS-1$
    assertEquals("LIMIT 100, 50", new Limit(new Constant(new Integer(100)), new Constant(new Integer(50))).toString());
    // $NON-NLS-1$
    assertEquals("LIMIT ?, ?", new Limit(new Reference(0), new Reference(1)).toString());
    // $NON-NLS-1$
    assertEquals("LIMIT -1, ?", new Limit(new Constant(new Integer(-1)), new Reference(1)).toString());
}
Also used : Constant(org.teiid.query.sql.symbol.Constant) Reference(org.teiid.query.sql.symbol.Reference)

Example 50 with Constant

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

the class TestLimit method testEquals.

public void testEquals() {
    Limit limit1 = new Limit(new Constant(new Integer(100)), new Constant(new Integer(50)));
    Limit limit2 = new Limit(new Constant(new Integer(100)), new Constant(new Integer(50)));
    Limit limit3 = new Limit(new Constant(new Integer(99)), new Constant(new Integer(50)));
    Limit limit4 = new Limit(new Constant(new Integer(100)), new Constant(new Integer(49)));
    Limit limit5 = new Limit(null, new Constant(new Integer(50)));
    Limit limit6 = new Limit(new Constant(new Integer(0)), new Constant(new Integer(50)));
    Limit limit7 = new Limit(new Reference(0), new Constant(new Integer(50)));
    Limit limit8 = new Limit(new Reference(0), new Reference(1));
    Limit limit9 = new Limit(null, new Reference(1));
    assertTrue(limit1.equals(limit2));
    assertTrue(limit2.equals(limit1));
    assertTrue(limit1.equals(limit1));
    assertFalse(limit1.equals(null));
    assertFalse(limit1.equals(limit3));
    assertFalse(limit1.equals(limit4));
    assertFalse(limit6.equals(limit7));
    assertFalse(limit7.equals(limit6));
    assertFalse(limit5.equals(limit7));
    assertFalse(limit7.equals(limit5));
    assertFalse(limit7.equals(limit8));
    assertFalse(limit8.equals(limit9));
    assertFalse(limit5.equals(limit9));
}
Also used : Constant(org.teiid.query.sql.symbol.Constant) Reference(org.teiid.query.sql.symbol.Reference)

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