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); }
public String toString(){ return criteria.toString(); }
/** * This utility method will pull apart a tree of criteria by breaking all * compound AND criteria apart. For instance, ((A=1 AND B=2) AND C=3) * will be broken into A=1, B=2, C=3. * @param crit Criteria to break apart * @return List of Criteria, empty list if crit is null */ public static List<Criteria> separateCriteriaByAnd(Criteria crit) { if(crit == null) { return Collections.emptyList(); } List<Criteria> parts = new ArrayList<Criteria>(); separateCriteria(crit, parts); return parts; }
private List<String> getCriteriaList() { List<String> critList = new ArrayList<String>(); if (leftExpressions != null) { for(int i=0; i < this.leftExpressions.size(); i++) { critList.add(this.leftExpressions.get(i).toString() + "=" + this.rightExpressions.get(i).toString()); //$NON-NLS-1$ } } if (this.joinCriteria != null) { for (Criteria crit : (List<Criteria>)Criteria.separateCriteriaByAnd(joinCriteria)) { critList.add(crit.toString()); } } return critList; }
List<Criteria> current = Criteria.separateCriteriaByAnd(query.getCriteria()); query.setCriteria(null); List<GroupSymbol> groups = query.getFrom().getGroups(); query.setCriteria(Criteria.combineCriteria(query.getCriteria(), Criteria.combineCriteria(current)));
delete.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(delete.getGroup(), metadata, Command.TYPE_DELETE, true)); if (info.getViewDefinition().getCriteria() != null) { delete.setCriteria(Criteria.combineCriteria(delete.getCriteria(), (Criteria)info.getViewDefinition().getCriteria().clone())); if (crit != null) { PostOrderNavigator.doVisit(crit, emv); query.setCriteria(Criteria.combineCriteria(query.getCriteria(), crit));
/** * This utility method can be used to combine two criteria using an AND. * If both criteria are null, then null will be returned. If either is null, * then the other will be returned. If neither is null and the primaryCrit is * a CompoundCriteria, then the additionalCrit will be added to the primaryCrit * and the primaryCrit will be returned. If the primaryCrit is not compound, a new * CompoundCriteria will be created and both criteria will be added to it. * @param primaryCrit Primary criteria - may be modified * @param additionalCrit Won't be modified, but will likely be attached to the returned crit * @return Combined criteria */ public static Criteria combineCriteria(Criteria primaryCrit, Criteria additionalCrit) { return combineCriteria(primaryCrit, additionalCrit, false); }
/** * Construct a JoinPredicate between two clauses of the specified type. * @param leftClause Left from clause * @param rightClause Right from clause * @param type Type of join * @param criteria List of Criteria for this join predicate */ public JoinPredicate(FromClause leftClause, FromClause rightClause, JoinType type, Criteria criteria) { this.leftClause = leftClause; this.rightClause = rightClause; this.joinType = type; this.joinCriteria = Criteria.separateCriteriaByAnd(criteria); }
/** * Convert the criteria from names using document identifiers to names using * result set (i.e. mapping class) identifiers. * @param simpleCrit Criteria to convert * @param rootNode Root of mapping node tree * @return Criteria Converted criteria * @throws QueryPlannerException if simpleCrit has a XML document model element * that is not mapped to data in a mapping class */ public static Criteria convertCriteria(Criteria simpleCrit, MappingDocument rootNode, QueryMetadataInterface metadata) throws QueryPlannerException, TeiidComponentException{ return convertObject((Criteria)simpleCrit.clone(), rootNode, metadata, true); }
for (Criteria conjunct : Criteria.separateCriteriaByAnd(crit)) { conjunct.acceptVisitor(visitor);
private Criteria rewriteCriteria(NotCriteria criteria) throws TeiidComponentException, TeiidProcessingException{ Criteria innerCrit = criteria.getCriteria(); if (innerCrit instanceof CompoundCriteria) { //reduce to only negation of predicates, so that the null/unknown handling criteria is applied appropriately return rewriteCriteria(Criteria.applyDemorgan(innerCrit)); } if(innerCrit == TRUE_CRITERIA) { return FALSE_CRITERIA; } else if(innerCrit == FALSE_CRITERIA) { return TRUE_CRITERIA; } else if (innerCrit == UNKNOWN_CRITERIA) { return UNKNOWN_CRITERIA; } if (innerCrit instanceof Negatable) { ((Negatable) innerCrit).negate(); return rewriteCriteria(innerCrit); } if (innerCrit instanceof NotCriteria) { return rewriteCriteria(((NotCriteria)innerCrit).getCriteria()); } Criteria newInnerCrit = rewriteCriteria(innerCrit); if (!newInnerCrit.equals(innerCrit)) { criteria.setCriteria(newInnerCrit); return rewriteCriteria(criteria); } return criteria; }
List<Criteria> current = Criteria.separateCriteriaByAnd(query.getCriteria()); query.setCriteria(null); List<GroupSymbol> groups = query.getFrom().getGroups(); query.setCriteria(Criteria.combineCriteria(query.getCriteria(), Criteria.combineCriteria(current)));
delete.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(delete.getGroup(), metadata, Command.TYPE_DELETE, true)); if (info.getViewDefinition().getCriteria() != null) { delete.setCriteria(Criteria.combineCriteria(delete.getCriteria(), (Criteria)info.getViewDefinition().getCriteria().clone())); if (crit != null) { PostOrderNavigator.doVisit(crit, emv); query.setCriteria(Criteria.combineCriteria(query.getCriteria(), crit));
/** * This utility method can be used to combine two criteria using an AND. * If both criteria are null, then null will be returned. If either is null, * then the other will be returned. If neither is null and the primaryCrit is * a CompoundCriteria, then the additionalCrit will be added to the primaryCrit * and the primaryCrit will be returned. If the primaryCrit is not compound, a new * CompoundCriteria will be created and both criteria will be added to it. * @param primaryCrit Primary criteria - may be modified * @param additionalCrit Won't be modified, but will likely be attached to the returned crit * @return Combined criteria */ public static Criteria combineCriteria(Criteria primaryCrit, Criteria additionalCrit) { return combineCriteria(primaryCrit, additionalCrit, false); }
/** * Construct a JoinPredicate between two clauses of the specified type. * @param leftClause Left from clause * @param rightClause Right from clause * @param type Type of join * @param criteria List of Criteria for this join predicate */ public JoinPredicate(FromClause leftClause, FromClause rightClause, JoinType type, Criteria criteria) { this.leftClause = leftClause; this.rightClause = rightClause; this.joinType = type; this.joinCriteria = Criteria.separateCriteriaByAnd(criteria); }
private List<String> getCriteriaList() { List<String> critList = new ArrayList<String>(); if (leftExpressions != null) { for(int i=0; i < this.leftExpressions.size(); i++) { critList.add(this.leftExpressions.get(i).toString() + "=" + this.rightExpressions.get(i).toString()); //$NON-NLS-1$ } } if (this.joinCriteria != null) { for (Criteria crit : (List<Criteria>)Criteria.separateCriteriaByAnd(joinCriteria)) { critList.add(crit.toString()); } } return critList; }
/** * Deep copy of object * @return Deep copy of object */ public Object clone() { return new NotCriteria( (Criteria) getCriteria().clone() ); }
for (Criteria conjunct : Criteria.separateCriteriaByAnd(crit)) { conjunct.acceptVisitor(visitor);
private Criteria rewriteCriteria(NotCriteria criteria) throws TeiidComponentException, TeiidProcessingException{ Criteria innerCrit = criteria.getCriteria(); if (innerCrit instanceof CompoundCriteria) { //reduce to only negation of predicates, so that the null/unknown handling criteria is applied appropriately return rewriteCriteria(Criteria.applyDemorgan(innerCrit)); } if(innerCrit == TRUE_CRITERIA) { return FALSE_CRITERIA; } else if(innerCrit == FALSE_CRITERIA) { return TRUE_CRITERIA; } else if (innerCrit == UNKNOWN_CRITERIA) { return UNKNOWN_CRITERIA; } if (innerCrit instanceof Negatable) { ((Negatable) innerCrit).negate(); return rewriteCriteria(innerCrit); } if (innerCrit instanceof NotCriteria) { return rewriteCriteria(((NotCriteria)innerCrit).getCriteria()); } Criteria newInnerCrit = rewriteCriteria(innerCrit); if (!newInnerCrit.equals(innerCrit)) { criteria.setCriteria(newInnerCrit); return rewriteCriteria(criteria); } return criteria; }
List<Criteria> current = Criteria.separateCriteriaByAnd(query.getCriteria()); query.setCriteria(null); List<GroupSymbol> groups = query.getFrom().getGroups(); query.setCriteria(Criteria.combineCriteria(query.getCriteria(), Criteria.combineCriteria(current)));