本文整理了Java中org.teiid.query.sql.lang.Query.<init>
方法的一些代码示例,展示了Query.<init>
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.<init>
方法的具体详情如下:
包路径:org.teiid.query.sql.lang.Query
类名称:Query
方法名:<init>
[英]Constructs a default instance of this class.
[中]构造该类的默认实例。
代码示例来源:origin: teiid/teiid
@Test public void testExistsCriteria() throws Exception {
ExistsCriteria crit = new ExistsCriteria(new Query());
ArrayList values = new ArrayList();
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
values.add("c"); //$NON-NLS-1$
helpTestCompareSubqueryCriteria(crit, true, values);
}
代码示例来源:origin: org.teiid/teiid-engine
public static Query createMatViewQuery(Object matMetadataId, String matTableName, List<? extends Expression> select, boolean isGlobal) {
Query query = new Query();
query.setSelect(new Select(select));
GroupSymbol gs = new GroupSymbol(matTableName);
gs.setGlobalTable(isGlobal);
gs.setMetadataID(matMetadataId);
query.setFrom(new From(Arrays.asList(new UnaryFromClause(gs))));
return query;
}
代码示例来源:origin: teiid/teiid
public void testConvertSubqueryCompareCriteria() throws Exception{
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
ElementSymbol x1 = new ElementSymbol("x1"); //$NON-NLS-1$
Map<ElementSymbol, ElementSymbol> symbolMap = new HashMap<ElementSymbol, ElementSymbol>();
symbolMap.put(e1, x1);
Query query = new Query();
SubqueryCompareCriteria crit = new SubqueryCompareCriteria(e1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
SubqueryCompareCriteria expected = new SubqueryCompareCriteria(x1, query, SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
FrameUtil.convertCriteria(crit, symbolMap, null, true);
assertEquals(crit, expected);
}
代码示例来源:origin: org.teiid/teiid-engine
public static Command createDeleteProcedure(Delete delete, QueryMetadataInterface metadata, CommandContext context) throws QueryResolverException, QueryMetadataException, TeiidComponentException, TeiidProcessingException {
QueryRewriter rewriter = new QueryRewriter(metadata, context);
Criteria crit = delete.getCriteria();
Query query = new Query(new Select(), new From(Arrays.asList(new UnaryFromClause(delete.getGroup()))), crit, null, null);
return rewriter.createDeleteProcedure(delete, query, delete.getGroup(), delete.getGroup().getName());
}
代码示例来源:origin: teiid/teiid
public static Command createDeleteProcedure(Delete delete, QueryMetadataInterface metadata, CommandContext context) throws QueryResolverException, QueryMetadataException, TeiidComponentException, TeiidProcessingException {
QueryRewriter rewriter = new QueryRewriter(metadata, context);
Criteria crit = delete.getCriteria();
Query query = new Query(new Select(), new From(Arrays.asList(new UnaryFromClause(delete.getGroup()))), crit, null, null);
return rewriter.createDeleteProcedure(delete, query, delete.getGroup(), delete.getGroup().getName());
}
代码示例来源:origin: teiid/teiid
@Test public void testPositionalReference() throws Exception {
String sql = "select $1";
Query query = new Query();
query.setSelect(new Select(Arrays.asList(new Reference(0))));
helpTest(sql, "SELECT ?", query);
}
代码示例来源:origin: teiid/teiid
@Test public void testNonReserved() throws Exception {
String sql = "select count";
Query query = new Query();
query.setSelect(new Select(Arrays.asList(new ElementSymbol("count"))));
helpTest(sql, "SELECT count", query);
}
代码示例来源:origin: teiid/teiid
@Test public void testLimitWithOffset() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(new Integer(50)), new Constant(new Integer(100))));
helpTest(query, "SELECT * FROM a LIMIT 50, 100"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testLimit() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(null, new Constant(new Integer(100))));
helpTest("Select * from a limit 100", "SELECT * FROM a LIMIT 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}
代码示例来源:origin: teiid/teiid
@Test public void testLimitWithReferences1() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Reference(0), new Constant(new Integer(100))));
helpTest("Select * from a limit ?,100", "SELECT * FROM a LIMIT ?, 100", query); //$NON-NLS-1$ //$NON-NLS-2$
}
代码示例来源:origin: teiid/teiid
private Query createTestQuery(String group) {
GroupSymbol g = new GroupSymbol(group);
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
Query query1 = new Query();
query1.setSelect(select);
query1.setFrom(from);
return query1;
}
代码示例来源:origin: teiid/teiid
@Test public void testFetchFirstRow() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(null, new Constant(1)));
helpTest("Select * from a fetch first row only", "SELECT * FROM a LIMIT 1", query); //$NON-NLS-1$ //$NON-NLS-2$
}
代码示例来源:origin: teiid/teiid
@Test public void testUnionJoin() {
String sql = "select * from pm1.g1 union join pm1.g2 where g1.e1 = 1"; //$NON-NLS-1$
String expected = "SELECT * FROM pm1.g1 UNION JOIN pm1.g2 WHERE g1.e1 = 1"; //$NON-NLS-1$
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addClause(new JoinPredicate(new UnaryFromClause(new GroupSymbol("pm1.g1")), new UnaryFromClause(new GroupSymbol("pm1.g2")), JoinType.JOIN_UNION)); //$NON-NLS-1$ //$NON-NLS-2$
Criteria crit = new CompareCriteria(new ElementSymbol("g1.e1"), CompareCriteria.EQ, new Constant(new Integer(1))); //$NON-NLS-1$
Query command = new Query(select, from, crit, null, null);
helpTest(sql, expected, command);
}
代码示例来源:origin: teiid/teiid
@Test public void testQuery1() {
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
helpTest(query, "SELECT * FROM m.g"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testCommandStatement1() {
Query q1 = new Query();
Select select = new Select();
select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$
q1.setSelect(select);
From from = new From();
from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
q1.setFrom(from);
CommandStatement cmdStmt = new CommandStatement(q1);
helpTest(cmdStmt, "SELECT x FROM g;"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testExistsCriteria1() {
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
From f1 = new From();
f1.addGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$
Query q1 = new Query();
q1.setSelect(s1);
q1.setFrom(f1);
ExistsCriteria ec = new ExistsCriteria(q1);
helpTest(ec, "EXISTS (SELECT e1 FROM m.g1)"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testScalarSubquery() {
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
From f1 = new From();
f1.addGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$
Query q1 = new Query();
q1.setSelect(s1);
q1.setFrom(f1);
ScalarSubquery obj = new ScalarSubquery(q1);
helpTest(obj, "(SELECT e1 FROM m.g1)"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testOptionalSubqueryFromClause1() {
Select s1 = new Select();
s1.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
From f1 = new From();
f1.addGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$
Query q1 = new Query();
q1.setSelect(s1);
q1.setFrom(f1);
SubqueryFromClause sfc = new SubqueryFromClause("temp", q1); //$NON-NLS-1$
sfc.setOptional(true);
helpTest(sfc, "/*+ optional */ (SELECT e1 FROM m.g1) AS temp"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testCommandStatement1a() {
Query q1 = new Query();
Select select = new Select();
select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$
q1.setSelect(select);
From from = new From();
from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
q1.setFrom(from);
CommandStatement cmdStmt = new CommandStatement(q1);
cmdStmt.setReturnable(false);
helpTest(cmdStmt, "SELECT x FROM g WITHOUT RETURN;"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testLOBTypes() throws Exception {
Function convert = new Function("convert", new Expression[] {new Constant(null), new Constant("blob")}); //$NON-NLS-1$ //$NON-NLS-2$
Function convert1 = new Function("convert", new Expression[] {new Constant(null), new Constant("clob")}); //$NON-NLS-1$ //$NON-NLS-2$
Function convert2 = new Function("convert", new Expression[] {new Constant(null), new Constant("xml")}); //$NON-NLS-1$ //$NON-NLS-2$
Select select = new Select(Arrays.asList(convert, convert1, convert2)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Query query = new Query();
query.setSelect(select);
helpTest("select convert(null, blob), convert(null, clob), convert(null, xml)", "SELECT convert(null, blob), convert(null, clob), convert(null, xml)", query); //$NON-NLS-1$ //$NON-NLS-2$
}
内容来源于网络,如有侵权,请联系作者删除!