Search in sources :

Example 56 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class XMLTableNode method processRow.

@Override
public synchronized void processRow(NodeInfo row) {
    if (isClosed()) {
        throw EARLY_TERMINATION;
    }
    assert this.state != State.DONE;
    this.item = row;
    rowCount++;
    try {
        this.buffer.addTuple(processRow());
        if (this.buffer.getRowCount() == rowLimit) {
            throw EARLY_TERMINATION;
        }
        if (state == State.BUILDING && hasNextBatch()) {
            this.state = State.AVAILABLE;
            this.notifyAll();
        }
    } catch (TeiidException e) {
        throw new TeiidRuntimeException(e);
    }
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidException(org.teiid.core.TeiidException)

Example 57 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class DdlPlan method alterProcedureDefinition.

public static void alterProcedureDefinition(final VDBMetaData vdb, final Procedure p, final String sql, boolean updateStore) {
    TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
    DatabaseStore store = vdb.getAttachment(DatabaseStore.class);
    try {
        Command command = QueryParser.getQueryParser().parseProcedure(p.getQueryPlan(), false);
        QueryResolver.resolveCommand(command, new GroupSymbol(p.getFullName()), Command.TYPE_STORED_PROCEDURE, metadata, false);
        MetadataValidator.determineDependencies(p, command);
    } catch (TeiidException e) {
    // should have been caught in validation, but this logic
    // is also not mature so since there is no lock on the vdb
    // it is possible that the plan is no longer valid at this point due
    // to a concurrent execution
    }
    p.setQueryPlan(sql);
    p.setLastModified(System.currentTimeMillis());
    // $NON-NLS-1$
    metadata.addToMetadataCache(p, "transformation/" + StoredProcedure.class.getSimpleName().toUpperCase(), null);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) DatabaseStore(org.teiid.query.metadata.DatabaseStore) StoredProcedure(org.teiid.query.sql.lang.StoredProcedure) Command(org.teiid.query.sql.lang.Command) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) TeiidException(org.teiid.core.TeiidException)

Example 58 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class DdlPlan method alterView.

public static void alterView(final VDBMetaData vdb, final Table t, final String sql, boolean updateStore) {
    TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
    DatabaseStore store = vdb.getAttachment(DatabaseStore.class);
    try {
        Command command = QueryParser.getQueryParser().parseCommand(t.getSelectTransformation());
        QueryResolver.resolveCommand(command, metadata);
        MetadataValidator.determineDependencies(t, command);
    } catch (TeiidException e) {
    // should have been caught in validation, but this logic
    // is also not mature so since there is no lock on the vdb
    // it is possible that the plan is no longer valid at this point due
    // to a concurrent execution
    }
    t.setSelectTransformation(sql);
    t.setLastModified(System.currentTimeMillis());
    // $NON-NLS-1$
    metadata.addToMetadataCache(t, "transformation/" + SQLConstants.Reserved.SELECT, null);
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) DatabaseStore(org.teiid.query.metadata.DatabaseStore) Command(org.teiid.query.sql.lang.Command) TeiidException(org.teiid.core.TeiidException)

Example 59 with TeiidException

use of org.teiid.core.TeiidException 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);
    }
}
Also used : Command(org.teiid.query.sql.lang.Command) AliasGenerator(org.teiid.query.optimizer.relational.AliasGenerator) Expression(org.teiid.query.sql.symbol.Expression) Reference(org.teiid.query.sql.symbol.Reference) ValueIteratorProviderCollectorVisitor(org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) ExpressionMappingVisitor(org.teiid.query.sql.visitor.ExpressionMappingVisitor) TeiidException(org.teiid.core.TeiidException)

Example 60 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class StatementImpl method execute.

private ResultsFuture<ResultsMessage> execute(final RequestMessage reqMsg, boolean synch) throws SQLException, TeiidSQLException {
    this.getConnection().beginLocalTxnIfNeeded();
    this.currentRequestID = this.driverConnection.nextRequestID();
    // Create a request message
    if (this.payload != null) {
        reqMsg.setExecutionPayload(this.payload);
    } else {
        reqMsg.setExecutionPayload(this.getMMConnection().getPayload());
    }
    reqMsg.setDelaySerialization(true);
    reqMsg.setCursorType(this.resultSetType);
    reqMsg.setFetchSize(this.fetchSize);
    reqMsg.setRowLimit(this.maxRows);
    reqMsg.setTransactionIsolation(this.driverConnection.getTransactionIsolation());
    reqMsg.setSync(synch && useCallingThread());
    // Get connection properties and set them onto request message
    copyPropertiesToRequest(reqMsg);
    reqMsg.setExecutionId(this.currentRequestID);
    ResultsFuture.CompletionListener<ResultsMessage> compeletionListener = null;
    if (queryTimeoutMS > 0 && (!synch || this.driverConnection.getServerConnection().isLocal())) {
        final Task c = cancellationTimer.add(cancelTask, queryTimeoutMS);
        compeletionListener = new ResultsFuture.CompletionListener<ResultsMessage>() {

            @Override
            public void onCompletion(ResultsFuture<ResultsMessage> future) {
                c.cancel();
            }
        };
    }
    ResultsFuture<ResultsMessage> pendingResult = null;
    try {
        pendingResult = this.getDQP().executeRequest(this.currentRequestID, reqMsg);
    } catch (TeiidException e) {
        throw TeiidSQLException.create(e);
    }
    if (compeletionListener != null) {
        pendingResult.addCompletionListener(compeletionListener);
    }
    return pendingResult;
}
Also used : ResultsFuture(org.teiid.client.util.ResultsFuture) Task(org.teiid.jdbc.EnhancedTimer.Task) ResultsMessage(org.teiid.client.ResultsMessage) TeiidException(org.teiid.core.TeiidException)

Aggregations

TeiidException (org.teiid.core.TeiidException)85 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)26 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)13 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)10 SQLException (java.sql.SQLException)9 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)8 BigInteger (java.math.BigInteger)6 Column (org.teiid.metadata.Column)6 Command (org.teiid.query.sql.lang.Command)6 TranslatorException (org.teiid.translator.TranslatorException)6 IOException (java.io.IOException)5 TeiidProcessingException (org.teiid.core.TeiidProcessingException)5 List (java.util.List)4 EdmEntityType (org.apache.olingo.commons.api.edm.EdmEntityType)4 ODataApplicationException (org.apache.olingo.server.api.ODataApplicationException)4 TeiidComponentException (org.teiid.core.TeiidComponentException)4 UpdateResponse (org.teiid.odata.api.UpdateResponse)4 Update (org.teiid.query.sql.lang.Update)4 SocketTimeoutException (java.net.SocketTimeoutException)3