updateSymbolMap(symbolMap, childRsInfo.getResultSetName(), inlineViewName, planEnv.getGlobalMetadata());
// check if the criteria has been raised, if it is then we can update this as a join.
if (childRsInfo.isCriteriaRaised()) {
Query transformationQuery = (Query) command;
SubqueryFromClause sfc = (SubqueryFromClause)transformationQuery.getFrom().getClauses().get(0);
Criteria joinCriteria = ((Query)childRsInfo.getCommand()).getCriteria();
if (joinCriteria == null) {
joinCriteria = QueryRewriter.TRUE_CRITERIA;
}
joinCriteria = (Criteria)joinCriteria.clone();
//update the from clause
FromClause clause = (FromClause)currentQuery.getFrom().getClauses().remove(0);
JoinPredicate join = null;
if (clause instanceof JoinPredicate) {
join = (JoinPredicate)clause;
FromClause right = join.getRightClause();
JoinPredicate newRight = new JoinPredicate(right, sfc, JoinType.JOIN_LEFT_OUTER, Criteria.separateCriteriaByAnd(joinCriteria));
join.setRightClause(newRight);
} else {
join = new JoinPredicate(clause, sfc, JoinType.JOIN_LEFT_OUTER, Criteria.separateCriteriaByAnd(joinCriteria));
}
currentQuery.getFrom().addClause(join);
currentQuery.getSelect().setDistinct(true);
continue;
}
if (!singleParentage) {
throw new QueryPlannerException(QueryPlugin.Util.getString("XMLQueryPlanner.cannot_plan", rsInfo.getCriteria())); //$NON-NLS-1$
}
Query subQuery = QueryUtil.wrapQuery(new SubqueryFromClause(inlineViewName, command), inlineViewName);
currentQuery.setCriteria(Criteria.combineCriteria(currentQuery.getCriteria(), new ExistsCriteria(subQuery)));
currentQuery = subQuery;
}