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);
}
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);
}
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);
}
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);
}
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;
}
}
Aggregations