Search in sources :

Example 96 with Constant

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

the class TestLimitParsing method testOffsetFetch.

@Test
public void testOffsetFetch() {
    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(2), new Constant(5)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a offset 2 rows fetch first 5 rows only", "SELECT * FROM a LIMIT 2, 5", 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 97 with Constant

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

the class TestSetQueryParsing method testUnionWithLimit.

@Test
public void testUnionWithLimit() {
    SetQuery setQuery = exampleSetQuery(Operation.UNION);
    setQuery.setLimit(new Limit(null, new Constant(1)));
    // $NON-NLS-1$
    TestParser.helpTest(// $NON-NLS-1$
    "SELECT a FROM g UNION select b from h LIMIT 1", // $NON-NLS-1$
    "SELECT a FROM g UNION SELECT b FROM h LIMIT 1", setQuery);
}
Also used : SetQuery(org.teiid.query.sql.lang.SetQuery) Constant(org.teiid.query.sql.symbol.Constant) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 98 with Constant

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

the class TestCapabilitiesUtil method testSupportsFunctionInGroupBy.

/**
 * Supports functions in group by is misleading.  It should actually
 * be called supports expression in group by.  Thus the example below
 * is not supported.
 */
@Test
public void testSupportsFunctionInGroupBy() throws Exception {
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Function f = new Function("concat", new Expression[] { new Constant("a"), new Constant("b") });
    // $NON-NLS-1$
    ExpressionSymbol expr = new ExpressionSymbol("e", f);
    List cols = new ArrayList();
    cols.add(expr);
    helpTestSupportsAggregates(false, false, cols);
}
Also used : Function(org.teiid.query.sql.symbol.Function) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ExpressionSymbol(org.teiid.query.sql.symbol.ExpressionSymbol) Test(org.junit.Test)

Example 99 with Constant

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

the class TestArrayProcessing method testMultiDimensionalArrayRewrite.

@Test
public void testMultiDimensionalArrayRewrite() throws Exception {
    // $NON-NLS-1$
    String sql = "select (('a', 'b'),('c','d'))";
    QueryResolver.resolveCommand(helpParse(sql), RealMetadataFactory.example1Cached());
    Command command = helpResolve(sql, RealMetadataFactory.example1Cached());
    assertEquals(String[][].class, command.getProjectedSymbols().get(0).getType());
    command = QueryRewriter.rewrite(command, RealMetadataFactory.example1Cached(), null);
    Expression ex = SymbolMap.getExpression(command.getProjectedSymbols().get(0));
    Constant c = (Constant) ex;
    assertTrue(c.getValue() instanceof ArrayImpl);
}
Also used : Command(org.teiid.query.sql.lang.Command) Expression(org.teiid.query.sql.symbol.Expression) Constant(org.teiid.query.sql.symbol.Constant) ArrayImpl(org.teiid.core.types.ArrayImpl) Test(org.junit.Test)

Example 100 with Constant

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

the class BaseIndexInfo method addSet.

void addSet(int i, Object match, Collection<Constant> values) {
    if (!valueSet.isEmpty()) {
        return;
    }
    if (i == 0) {
        for (Constant constant : values) {
            List<Object> value = new ArrayList<Object>(table.getPkLength());
            Object value2 = constant.getValue();
            buildSearchRow(i, match, value2, value);
            valueSet.add(value);
        }
        lower = null;
        upper = null;
    }
}
Also used : Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList)

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