use of org.teiid.query.sql.lang.QueryCommand in project teiid by teiid.
the class ConnectorWorkItem method setExecution.
private void setExecution(Command command, org.teiid.language.Command translatedCommand, final Execution exec) {
if (translatedCommand instanceof Call) {
// $NON-NLS-1$
this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions");
StoredProcedure proc = (StoredProcedure) command;
if (proc.returnParameters()) {
this.procedureBatchHandler = new ProcedureBatchHandler((Call) translatedCommand, (ProcedureExecution) exec);
}
} else if (command instanceof QueryCommand) {
// $NON-NLS-1$
this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions");
} else {
final boolean singleUpdateCount = connector.returnsSingleUpdateCount() && (translatedCommand instanceof BatchedUpdates || (translatedCommand instanceof BulkCommand && ((BulkCommand) translatedCommand).getParameterValues() != null));
// $NON-NLS-1$
Assertion.isInstanceOf(exec, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions");
this.execution = new ResultSetExecution() {
private int[] results;
private int index;
@Override
public void cancel() throws TranslatorException {
exec.cancel();
}
@Override
public void close() {
exec.close();
}
@Override
public void execute() throws TranslatorException {
exec.execute();
}
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (results == null) {
results = ((UpdateExecution) exec).getUpdateCounts();
}
if (singleUpdateCount) {
if (index++ < results[0]) {
return CollectionTupleSource.UPDATE_ROW;
}
return null;
}
if (index < results.length) {
return Arrays.asList(results[index++]);
}
return null;
}
};
}
}
use of org.teiid.query.sql.lang.QueryCommand in project teiid by teiid.
the class SetQueryResolver method resolveCommand.
/**
* @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, TempMetadataAdapter, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, boolean resolveNullLiterals) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
SetQuery setQuery = (SetQuery) command;
SimpleQueryResolver.resolveWith(metadata, setQuery);
QueryCommand firstCommand = setQuery.getLeftQuery();
QueryResolver.setChildMetadata(firstCommand, setQuery);
QueryResolver.resolveCommand(firstCommand, metadata.getMetadata(), false);
QueryCommand rightCommand = setQuery.getRightQuery();
QueryResolver.setChildMetadata(rightCommand, setQuery);
QueryResolver.resolveCommand(rightCommand, metadata.getMetadata(), false);
resolveSetQuery(metadata, resolveNullLiterals, setQuery, firstCommand, rightCommand);
}
Aggregations