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);
}
}
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);
}
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);
}
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);
}
}
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;
}
Aggregations