Search in sources :

Example 1 with WithQueryCommand

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();
}
Also used : SetQuery(org.teiid.query.sql.lang.SetQuery) WithQueryCommand(org.teiid.query.sql.lang.WithQueryCommand)

Example 2 with WithQueryCommand

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;
}
Also used : TupleBuffer(org.teiid.common.buffer.TupleBuffer) QueryCommand(org.teiid.query.sql.lang.QueryCommand) WithQueryCommand(org.teiid.query.sql.lang.WithQueryCommand) WithQueryCommand(org.teiid.query.sql.lang.WithQueryCommand)

Example 3 with WithQueryCommand

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);
}
Also used : SetQuery(org.teiid.query.sql.lang.SetQuery) WithQueryCommand(org.teiid.query.sql.lang.WithQueryCommand)

Example 4 with WithQueryCommand

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();
}
Also used : SetQuery(org.teiid.query.sql.lang.SetQuery) HashMap(java.util.HashMap) RecursiveTableProcessor(org.teiid.query.tempdata.TempTableStore.RecursiveTableProcessor) TableProcessor(org.teiid.query.tempdata.TempTableStore.TableProcessor) WithQueryCommand(org.teiid.query.sql.lang.WithQueryCommand) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) QueryProcessor(org.teiid.query.processor.QueryProcessor) RecursiveTableProcessor(org.teiid.query.tempdata.TempTableStore.RecursiveTableProcessor)

Example 5 with WithQueryCommand

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();
            }
        }
    }
}
Also used : SetQuery(org.teiid.query.sql.lang.SetQuery) WithQueryCommand(org.teiid.query.sql.lang.WithQueryCommand)

Aggregations

WithQueryCommand (org.teiid.query.sql.lang.WithQueryCommand)6 SetQuery (org.teiid.query.sql.lang.SetQuery)5 HashMap (java.util.HashMap)1 TupleBuffer (org.teiid.common.buffer.TupleBuffer)1 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)1 QueryProcessor (org.teiid.query.processor.QueryProcessor)1 QueryCommand (org.teiid.query.sql.lang.QueryCommand)1 RecursiveTableProcessor (org.teiid.query.tempdata.TempTableStore.RecursiveTableProcessor)1 TableProcessor (org.teiid.query.tempdata.TempTableStore.TableProcessor)1