本文整理了Java中org.teiid.query.sql.lang.Query.setGroupBy
方法的一些代码示例,展示了Query.setGroupBy
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setGroupBy
方法的具体详情如下:
包路径:org.teiid.query.sql.lang.Query
类名称:Query
方法名:setGroupBy
[英]Set the group by clause for the query.
[中]为查询设置group by子句。
代码示例来源:origin: org.teiid/teiid-engine
private Query rewriteGroupBy(Query query) throws TeiidComponentException, TeiidProcessingException {
if (query.getGroupBy() == null) {
rewriteAggs = false;
return query;
}
if (isDistinctWithGroupBy(query)) {
query.getSelect().setDistinct(false);
}
rewriteExpressions(query.getGroupBy());
List<Expression> expr = query.getGroupBy().getSymbols();
for (Iterator<Expression> iter = expr.iterator(); iter.hasNext();) {
if (EvaluatableVisitor.willBecomeConstant(iter.next())) {
iter.remove();
}
}
if (expr.isEmpty()) {
query.setGroupBy(null);
}
return query;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
private Query rewriteGroupBy(Query query) throws TeiidComponentException, TeiidProcessingException {
if (query.getGroupBy() == null) {
rewriteAggs = false;
return query;
}
if (isDistinctWithGroupBy(query)) {
query.getSelect().setDistinct(false);
}
rewriteExpressions(query.getGroupBy());
List<Expression> expr = query.getGroupBy().getSymbols();
for (Iterator<Expression> iter = expr.iterator(); iter.hasNext();) {
if (EvaluatableVisitor.willBecomeConstant(iter.next())) {
iter.remove();
}
}
if (expr.isEmpty()) {
query.setGroupBy(null);
}
return query;
}
代码示例来源:origin: teiid/teiid
private Query rewriteGroupBy(Query query) throws TeiidComponentException, TeiidProcessingException {
if (query.getGroupBy() == null) {
rewriteAggs = false;
return query;
}
if (isDistinctWithGroupBy(query)) {
query.getSelect().setDistinct(false);
}
rewriteExpressions(query.getGroupBy());
List<Expression> expr = query.getGroupBy().getSymbols();
for (Iterator<Expression> iter = expr.iterator(); iter.hasNext();) {
if (EvaluatableVisitor.willBecomeConstant(iter.next())) {
iter.remove();
}
}
if (expr.isEmpty()) {
query.setGroupBy(null);
}
return query;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
/**
* Constructs an instance of this class given all the clauses
* @param select SELECT clause
* @param from FROM clause
* @param criteria WHERE clause
* @param groupBy GROUP BY clause
* @param having HAVING clause
* @param orderBy ORDER BY clause
* @param option OPTION clause
*/
public Query( Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option ) {
super();
setSelect( select );
setFrom( from );
setCriteria( criteria );
setGroupBy( groupBy );
setHaving( having );
setOrderBy( orderBy );
setOption( option );
}
代码示例来源:origin: org.teiid/teiid-engine
/**
* Constructs an instance of this class given all the clauses
* @param select SELECT clause
* @param from FROM clause
* @param criteria WHERE clause
* @param groupBy GROUP BY clause
* @param having HAVING clause
* @param orderBy ORDER BY clause
* @param option OPTION clause
*/
public Query( Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option ) {
super();
setSelect( select );
setFrom( from );
setCriteria( criteria );
setGroupBy( groupBy );
setHaving( having );
setOrderBy( orderBy );
setOption( option );
}
代码示例来源:origin: teiid/teiid
/**
* Constructs an instance of this class given all the clauses
* @param select SELECT clause
* @param from FROM clause
* @param criteria WHERE clause
* @param groupBy GROUP BY clause
* @param having HAVING clause
* @param orderBy ORDER BY clause
* @param option OPTION clause
*/
public Query( Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option ) {
super();
setSelect( select );
setFrom( from );
setCriteria( criteria );
setGroupBy( groupBy );
setHaving( having );
setOrderBy( orderBy );
setOption( option );
}
代码示例来源:origin: org.teiid/teiid-olingo
groupBy.addSymbol(new ElementSymbol(keyCol, this.groupSymbol));
query.setGroupBy(groupBy);
代码示例来源:origin: teiid/teiid
@Test public void testQuery6() {
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setCriteria(cc);
query.setGroupBy(groupBy);
query.setHaving(having);
helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 HAVING e1 > 0"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testQuery2() {
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
OrderBy orderBy = new OrderBy();
orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setCriteria(cc);
query.setGroupBy(groupBy);
query.setHaving(having);
query.setOrderBy(orderBy);
helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 HAVING e1 > 0 ORDER BY e1"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testQuery7() {
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
OrderBy orderBy = new OrderBy();
orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setCriteria(cc);
query.setGroupBy(groupBy);
query.setHaving(having);
query.setOrderBy(orderBy);
helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 HAVING e1 > 0 ORDER BY e1"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
query.setSelect(select);
query.setFrom(from);
query.setGroupBy(groupBy);
query.setHaving(having);
代码示例来源:origin: teiid/teiid
/** SELECT a FROM m.g GROUP BY b, c HAVING b=5*/
@Test public void testGroupByHaving() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new ElementSymbol("a", false)); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("b", false)); //$NON-NLS-1$
groupBy.addSymbol(new ElementSymbol("c", false)); //$NON-NLS-1$
CompareCriteria having = new CompareCriteria(new ElementSymbol("b", false), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setGroupBy(groupBy);
query.setHaving(having);
helpTest("SELECT a FROM m.g GROUP BY b, c HAVING b=5", //$NON-NLS-1$
"SELECT a FROM m.g GROUP BY b, c HAVING b = 5", //$NON-NLS-1$
query);
}
代码示例来源:origin: teiid/teiid
@Test public void testQuery3() {
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
OrderBy orderBy = new OrderBy();
orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setGroupBy(groupBy);
query.setHaving(having);
query.setOrderBy(orderBy);
helpTest(query, "SELECT * FROM m.g GROUP BY e1 HAVING e1 > 0 ORDER BY e1"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
@Test public void testQuery5() {
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from = new From();
from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
OrderBy orderBy = new OrderBy();
orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setCriteria(cc);
query.setGroupBy(groupBy);
query.setOrderBy(orderBy);
helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 ORDER BY e1"); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
/** SELECT a FROM m.g GROUP BY a HAVING COUNT(b) > 0*/
@Test public void testHavingFunction() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
Criteria having = new CompareCriteria(
new AggregateSymbol("COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
CompareCriteria.GT,
new Constant(new Integer(0)) );
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setGroupBy(groupBy);
query.setHaving(having);
helpTest("SELECT a FROM m.g GROUP BY a HAVING COUNT(b) > 0", //$NON-NLS-1$
"SELECT a FROM m.g GROUP BY a HAVING COUNT(b) > 0", //$NON-NLS-1$
query);
}
代码示例来源:origin: teiid/teiid
copy.setGroupBy( (GroupBy) groupBy.clone());
代码示例来源:origin: org.teiid/teiid-engine
copy.setGroupBy( (GroupBy) groupBy.clone());
代码示例来源:origin: teiid/teiid
/** SELECT a FROM m.g GROUP BY b, c */
@Test public void testGroupBy() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new ElementSymbol("a", false)); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.addSymbol(new ElementSymbol("b", false)); //$NON-NLS-1$
groupBy.addSymbol(new ElementSymbol("c", false)); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setGroupBy(groupBy);
helpTest("SELECT a FROM m.g GROUP BY b, c", //$NON-NLS-1$
"SELECT a FROM m.g GROUP BY b, c", //$NON-NLS-1$
query);
}
代码示例来源:origin: teiid/teiid
@Test public void testGroupByRollup() {
GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new ElementSymbol("a", false)); //$NON-NLS-1$
GroupBy groupBy = new GroupBy();
groupBy.setRollup(true);
groupBy.addSymbol(new ElementSymbol("b", false)); //$NON-NLS-1$
groupBy.addSymbol(new ElementSymbol("c", false)); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setGroupBy(groupBy);
helpTest("SELECT a FROM m.g GROUP BY rollup(b, c)", //$NON-NLS-1$
"SELECT a FROM m.g GROUP BY ROLLUP(b, c)", //$NON-NLS-1$
query);
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
copy.setGroupBy( (GroupBy) groupBy.clone());
内容来源于网络,如有侵权,请联系作者删除!