本文整理了Java中org.teiid.query.sql.lang.Query.setHaving
方法的一些代码示例,展示了Query.setHaving
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setHaving
方法的具体详情如下:
包路径:org.teiid.query.sql.lang.Query
类名称:Query
方法名:setHaving
[英]Set the criteria clause for the query.
[中]
代码示例来源:origin: org.teiid/teiid-engine
private static boolean shouldEvaluate(boolean simplifyCriteria,
boolean duringPlanning, Criteria criteria, Query query, boolean having)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException {
if(criteria == null) {
return true;
} else if(!EvaluatableVisitor.isFullyEvaluatable(criteria, duringPlanning)) {
// If there are elements present in the criteria,
// then we don't know the result, so assume we need to execute
return true;
} else if(Evaluator.evaluate(criteria)) {
if (simplifyCriteria) {
if (having) {
query.setHaving(null);
} else {
query.setCriteria(null);
}
}
return true;
}
return false;
}
代码示例来源:origin: teiid/teiid
private static boolean shouldEvaluate(boolean simplifyCriteria,
boolean duringPlanning, Criteria criteria, Query query, boolean having)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException {
if(criteria == null) {
return true;
} else if(!EvaluatableVisitor.isFullyEvaluatable(criteria, duringPlanning)) {
// If there are elements present in the criteria,
// then we don't know the result, so assume we need to execute
return true;
} else if(Evaluator.evaluate(criteria)) {
if (simplifyCriteria) {
if (having) {
query.setHaving(null);
} else {
query.setCriteria(null);
}
}
return true;
}
return false;
}
代码示例来源:origin: org.teiid/teiid-engine
private void processCriteria(Collection<GroupSymbol> leftGroups,
PlannedResult plannedResult, List<GroupSymbol> rightGroups,
Set<Expression> requiredExpressions, final SymbolMap refs,
Criteria joinCriteria, GroupBy groupBy, boolean where) {
if (joinCriteria == null) {
return;
}
List<Criteria> crits = Criteria.separateCriteriaByAnd((Criteria)joinCriteria.clone());
for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
Criteria conjunct = critIter.next();
List<Expression> additionalRequired = new LinkedList<Expression>();
AggregateSymbolCollectorVisitor.getAggregates(conjunct, additionalRequired, additionalRequired, additionalRequired, null, groupBy!=null?groupBy.getSymbols():null);
ReferenceReplacementVisitor emv = new ReferenceReplacementVisitor(refs);
DeepPostOrderNavigator.doVisit(conjunct, emv);
if (!emv.replacedAny) {
//if not correlated, then leave it on the query
critIter.remove();
if (where) {
plannedResult.query.setCriteria(Criteria.combineCriteria(plannedResult.query.getCriteria(), conjunct));
} else {
plannedResult.query.setHaving(Criteria.combineCriteria(plannedResult.query.getHaving(), conjunct));
}
} else {
requiredExpressions.addAll(additionalRequired);
}
}
RuleChooseJoinStrategy.separateCriteria(leftGroups, rightGroups, plannedResult.leftExpressions, plannedResult.rightExpressions, crits, plannedResult.nonEquiJoinCriteria);
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
private void processCriteria(Collection<GroupSymbol> leftGroups,
PlannedResult plannedResult, List<GroupSymbol> rightGroups,
Set<Expression> requiredExpressions, final SymbolMap refs,
Criteria joinCriteria, GroupBy groupBy, boolean where) {
if (joinCriteria == null) {
return;
}
List<Criteria> crits = Criteria.separateCriteriaByAnd((Criteria)joinCriteria.clone());
for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
Criteria conjunct = critIter.next();
List<Expression> additionalRequired = new LinkedList<Expression>();
AggregateSymbolCollectorVisitor.getAggregates(conjunct, additionalRequired, additionalRequired, additionalRequired, null, groupBy!=null?groupBy.getSymbols():null);
ReferenceReplacementVisitor emv = new ReferenceReplacementVisitor(refs);
DeepPostOrderNavigator.doVisit(conjunct, emv);
if (!emv.replacedAny) {
//if not correlated, then leave it on the query
critIter.remove();
if (where) {
plannedResult.query.setCriteria(Criteria.combineCriteria(plannedResult.query.getCriteria(), conjunct));
} else {
plannedResult.query.setHaving(Criteria.combineCriteria(plannedResult.query.getHaving(), conjunct));
}
} else {
requiredExpressions.addAll(additionalRequired);
}
}
RuleChooseJoinStrategy.separateCriteria(leftGroups, rightGroups, plannedResult.leftExpressions, plannedResult.rightExpressions, crits, plannedResult.nonEquiJoinCriteria);
}
代码示例来源:origin: teiid/teiid
private void processCriteria(Collection<GroupSymbol> leftGroups,
PlannedResult plannedResult, List<GroupSymbol> rightGroups,
Set<Expression> requiredExpressions, final SymbolMap refs,
Criteria joinCriteria, GroupBy groupBy, boolean where) {
if (joinCriteria == null) {
return;
}
List<Criteria> crits = Criteria.separateCriteriaByAnd((Criteria)joinCriteria.clone());
for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
Criteria conjunct = critIter.next();
List<Expression> additionalRequired = new LinkedList<Expression>();
AggregateSymbolCollectorVisitor.getAggregates(conjunct, additionalRequired, additionalRequired, additionalRequired, null, groupBy!=null?groupBy.getSymbols():null);
ReferenceReplacementVisitor emv = new ReferenceReplacementVisitor(refs);
DeepPostOrderNavigator.doVisit(conjunct, emv);
if (!emv.replacedAny) {
//if not correlated, then leave it on the query
critIter.remove();
if (where) {
plannedResult.query.setCriteria(Criteria.combineCriteria(plannedResult.query.getCriteria(), conjunct));
} else {
plannedResult.query.setHaving(Criteria.combineCriteria(plannedResult.query.getHaving(), conjunct));
}
} else {
requiredExpressions.addAll(additionalRequired);
}
}
RuleChooseJoinStrategy.separateCriteria(leftGroups, rightGroups, plannedResult.leftExpressions, plannedResult.rightExpressions, crits, plannedResult.nonEquiJoinCriteria);
}
代码示例来源: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: 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-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
@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 testQuery4() {
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$
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.setHaving(having);
query.setOrderBy(orderBy);
helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 HAVING e1 > 0 ORDER BY e1"); //$NON-NLS-1$
}
代码示例来源:origin: org.teiid/teiid-engine
query.setCriteria(criteria);
query.setGroupBy(groupBy);
query.setHaving(having);
代码示例来源: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.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
/** 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: org.teiid/teiid-engine
copy.setHaving( (Criteria) having.clone());
代码示例来源:origin: teiid/teiid
copy.setHaving( (Criteria) having.clone());
代码示例来源:origin: org.jboss.teiid/teiid-engine
copy.setHaving( (Criteria) having.clone());
内容来源于网络,如有侵权,请联系作者删除!