use of org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor in project teiid by teiid.
the class CommandBuilder method getCommand.
public org.teiid.language.Command getCommand(String queryString, boolean generateAliases, boolean supportsGroupAlias) {
Command command = null;
try {
command = QueryParser.getQueryParser().parseCommand(queryString);
QueryResolver.resolveCommand(command, metadata);
command = QueryRewriter.rewrite(command, metadata, null);
expandAllSymbol(command);
if (generateAliases) {
command = (Command) command.clone();
command.acceptVisitor(new AliasGenerator(supportsGroupAlias));
}
// the language bridge doesn't expect References
ValueIteratorProviderCollectorVisitor v = new ValueIteratorProviderCollectorVisitor();
v.setCollectLateral(true);
PreOrderNavigator.doVisit(command, v);
for (SubqueryContainer<?> container : v.getValueIteratorProviders()) {
ExpressionMappingVisitor visitor = new ExpressionMappingVisitor(null) {
@Override
public Expression replaceExpression(Expression element) {
if (element instanceof Reference) {
return ((Reference) element).getExpression();
}
return element;
}
};
DeepPostOrderNavigator.doVisit(command, visitor);
}
return languageBridgeFactory.translate(command);
} catch (TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
Aggregations