QueryMetadataInterface metadata,
List<? extends SingleElementSymbol> actualSymbols) throws QueryMetadataException,
QueryResolverException,
TeiidComponentException {
Query query = new Query();
Select select = new Select();
query.setSelect(select);
From from = new From();
from.addClause(new UnaryFromClause(inlineGroup));
TempMetadataStore store = new TempMetadataStore();
TempMetadataAdapter tma = new TempMetadataAdapter(metadata, store);
if (nested instanceof QueryCommand) {
Query firstProject = ((QueryCommand)nested).getProjectedQuery();
makeSelectUnique(firstProject.getSelect(), false);
}
TempMetadataID gid = store.addTempGroup(inlineGroup.getName(), nested.getProjectedSymbols());
inlineGroup.setMetadataID(gid);
List<Class<?>> actualTypes = new ArrayList<Class<?>>(nested.getProjectedSymbols().size());
for (SingleElementSymbol ses : actualSymbols) {
actualTypes.add(ses.getType());
}
List<SingleElementSymbol> selectSymbols = SetQuery.getTypedProjectedSymbols(ResolverUtil.resolveElementsInGroup(inlineGroup, tma), actualTypes, tma);
Iterator<? extends SingleElementSymbol> iter = actualSymbols.iterator();
for (SingleElementSymbol ses : selectSymbols) {
ses = (SingleElementSymbol)ses.clone();
SingleElementSymbol actual = iter.next();
if (!ses.getShortCanonicalName().equals(actual.getShortCanonicalName())) {
if (ses instanceof AliasSymbol) {
((AliasSymbol)ses).setShortName(actual.getShortName());
} else {
ses = new AliasSymbol(actual.getShortName(), ses);
}
}
select.addSymbol(ses);
}
query.setFrom(from);
QueryResolver.resolveCommand(query, tma);
query.setOption(nested.getOption());
from.getClauses().clear();