use of org.teiid.query.sql.lang.WithQueryCommand in project teiid by teiid.
the class RelationalPlan method toString.
public String toString() {
StringBuilder sb = new StringBuilder();
if (this.with != null) {
sb.append(SQLConstants.Reserved.WITH);
for (WithQueryCommand withCommand : this.with) {
// $NON-NLS-1$
sb.append("\n");
sb.append(withCommand.getGroupSymbol());
if (withCommand.isRecursive()) {
// $NON-NLS-1$
sb.append(" anchor\n").append(((SetQuery) withCommand.getCommand()).getLeftQuery().getProcessorPlan());
// $NON-NLS-1$
sb.append("recursive\n").append(((SetQuery) withCommand.getCommand()).getRightQuery().getProcessorPlan());
} else {
// $NON-NLS-1$
sb.append("\n");
sb.append(withCommand.getCommand().getProcessorPlan());
}
}
// $NON-NLS-1$
sb.append("body\n");
}
sb.append(this.root.toString());
return sb.toString();
}
use of org.teiid.query.sql.lang.WithQueryCommand in project teiid by teiid.
the class AccessNode method nextCommand.
@SuppressWarnings("unused")
protected Command nextCommand() throws TeiidProcessingException, TeiidComponentException {
// to ensure that the subquery ids remain stable
if (nextCommand == null) {
nextCommand = (Command) processingCommand.clone();
if (evaluatedPlans != null) {
for (WithQueryCommand with : ((QueryCommand) nextCommand).getWith()) {
TupleBuffer tb = evaluatedPlans.get(with.getGroupSymbol()).collector.getTupleBuffer();
with.setTupleBuffer(tb);
}
}
}
return nextCommand;
}
use of org.teiid.query.sql.lang.WithQueryCommand in project teiid by teiid.
the class RelationalPlan method requiresTransaction.
@Override
public Boolean requiresTransaction(boolean transactionalReads) {
if (this.with != null) {
for (WithQueryCommand withCommand : this.with) {
if (withCommand.isRecursive()) {
SetQuery setQuery = (SetQuery) withCommand.getCommand();
Boolean leftRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads);
Boolean rightRequires = setQuery.getLeftQuery().getProcessorPlan().requiresTransaction(transactionalReads);
if (!Boolean.FALSE.equals(leftRequires) || !Boolean.FALSE.equals(rightRequires)) {
return true;
}
} else {
Boolean requires = withCommand.getCommand().getProcessorPlan().requiresTransaction(transactionalReads);
if (!Boolean.FALSE.equals(requires)) {
return true;
}
}
}
}
return requiresTransaction(transactionalReads, root);
}
use of org.teiid.query.sql.lang.WithQueryCommand in project teiid by teiid.
the class RelationalPlan method open.
@Override
public void open() throws TeiidComponentException, TeiidProcessingException {
if (with != null && tempTableStore.getProcessors() == null) {
HashMap<String, TableProcessor> processors = new HashMap<String, TableProcessor>();
tempTableStore.setProcessors(processors);
for (WithQueryCommand withCommand : this.with) {
if (withCommand.isRecursive()) {
SetQuery setQuery = (SetQuery) withCommand.getCommand();
ProcessorPlan initial = setQuery.getLeftQuery().getProcessorPlan();
QueryProcessor withProcessor = new QueryProcessor(initial, getContext().clone(), root.getBufferManager(), root.getDataManager());
processors.put(withCommand.getGroupSymbol().getName(), new RecursiveTableProcessor(withProcessor, withCommand.getColumns(), setQuery.getRightQuery().getProcessorPlan(), setQuery.isAll()));
continue;
}
ProcessorPlan plan = withCommand.getCommand().getProcessorPlan();
QueryProcessor withProcessor = new QueryProcessor(plan, getContext().clone(), root.getBufferManager(), root.getDataManager());
processors.put(withCommand.getGroupSymbol().getName(), new TableProcessor(withProcessor, withCommand.getColumns()));
}
}
this.root.open();
}
use of org.teiid.query.sql.lang.WithQueryCommand in project teiid by teiid.
the class RelationalPlan method reset.
/**
* @see org.teiid.query.processor.ProcessorPlan#reset()
*/
public void reset() {
super.reset();
this.root.reset();
if (this.with != null) {
for (WithQueryCommand withCommand : this.with) {
if (withCommand.isRecursive()) {
SetQuery setQuery = (SetQuery) withCommand.getCommand();
setQuery.getLeftQuery().getProcessorPlan().reset();
setQuery.getLeftQuery().getProcessorPlan().reset();
} else {
withCommand.getCommand().getProcessorPlan().reset();
}
}
}
}
Aggregations