use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class AccessNode method openInternal.
private void openInternal() throws TeiidComponentException, TeiidProcessingException {
// TODO: support a partitioning concept with multi-source and full dependent join pushdown
if (subPlans != null) {
if (this.evaluatedPlans == null) {
this.evaluatedPlans = new HashMap<GroupSymbol, SubqueryState>();
for (Map.Entry<GroupSymbol, RelationalPlan> entry : subPlans.entrySet()) {
SubqueryState state = new SubqueryState();
RelationalPlan value = entry.getValue();
value.reset();
state.processor = new QueryProcessor(value, getContext().clone(), getBufferManager(), getDataManager());
state.collector = state.processor.createBatchCollector();
this.evaluatedPlans.put(entry.getKey(), state);
}
}
BlockedException be = null;
for (SubqueryState state : evaluatedPlans.values()) {
try {
state.collector.collectTuples();
} catch (BlockedException e) {
be = e;
}
}
if (be != null) {
throw be;
}
}
/*
* Check to see if we need a multi-source expansion. If the connectorBindingExpression != null, then
* the logic below will handle that case
*/
if (multiSource && connectorBindingExpression == null) {
synchronized (this) {
// the description can be obtained asynchly, so we need to synchronize
VDBMetaData vdb = getContext().getVdb();
ModelMetaData model = vdb.getModel(getModelName());
List<String> sources = model.getSourceNames();
// make sure that we have the right nodes
if (this.getChildCount() != 0 && (this.sourceNames == null || !this.sourceNames.equals(sources))) {
this.childCount--;
this.getChildren()[0] = null;
}
if (this.getChildCount() == 0) {
sourceNames = sources;
RelationalNode node = multiSourceModify(this, connectorBindingExpression, getContext().getMetadata(), sourceNames);
RelationalPlan.connectExternal(node, getContext(), getDataManager(), getBufferManager());
this.addChild(node);
}
}
this.getChildren()[0].open();
return;
}
// Copy command and resolve references if necessary
if (processingCommand == null) {
processingCommand = command;
isUpdate = RelationalNodeUtil.isUpdate(command);
}
boolean needProcessing = true;
if (this.connectorBindingExpression != null && connectorBindingId == null) {
this.connectorBindingId = (String) getEvaluator(Collections.emptyMap()).evaluate(this.connectorBindingExpression, null);
VDBMetaData vdb = getContext().getVdb();
ModelMetaData model = vdb.getModel(getModelName());
List<String> sources = model.getSourceNames();
String replacement = this.connectorBindingId;
if (!sources.contains(this.connectorBindingId)) {
shouldExecute = false;
if (command instanceof StoredProcedure) {
StoredProcedure sp = (StoredProcedure) command;
if (sp.returnParameters() && sp.getProjectedSymbols().size() > sp.getResultSetColumns().size()) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30561, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30561, command));
}
}
return;
}
if (!(command instanceof StoredProcedure || command instanceof Insert)) {
processingCommand = (Command) command.clone();
MultiSourceElementReplacementVisitor.visit(replacement, getContext().getMetadata(), processingCommand);
}
}
do {
Command atomicCommand = nextCommand();
if (shouldEvaluate) {
needProcessing = prepareNextCommand(atomicCommand);
nextCommand = null;
} else {
needProcessing = RelationalNodeUtil.shouldExecute(atomicCommand, true);
}
if (needProcessing) {
registerRequest(atomicCommand);
}
// We use an upper limit here to the currency because these commands have potentially large in-memory value sets
} while (!processCommandsIndividually() && hasNextCommand() && this.tupleSources.size() < Math.max(Math.min(MAX_CONCURRENT, this.getContext().getUserRequestSourceConcurrency()), this.getContext().getUserRequestSourceConcurrency() / 2));
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class SQLParserUtil method createDDLTrigger.
void createDDLTrigger(DatabaseStore events, AlterTrigger trigger) {
GroupSymbol group = trigger.getTarget();
events.setTableTriggerPlan(trigger.getName(), group.getName(), trigger.getEvent(), trigger.getDefinition().toString(), trigger.isAfter());
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestUpdateValidator method helpTest.
private UpdateValidator helpTest(String sql, TransformationMetadata md, boolean failInsert, boolean failUpdate, boolean failDelete) {
try {
String vGroup = "gx";
Command command = createView(sql, md, vGroup);
UpdateValidator uv = new UpdateValidator(md, UpdateType.INHERENT, UpdateType.INHERENT, UpdateType.INHERENT);
GroupSymbol gs = new GroupSymbol(vGroup);
ResolverUtil.resolveGroup(gs, md);
uv.validate(command, ResolverUtil.resolveElementsInGroup(gs, md));
UpdateInfo info = uv.getUpdateInfo();
assertEquals(uv.getReport().getFailureMessage(), failInsert, info.getInsertValidationError() != null);
assertEquals(uv.getReport().getFailureMessage(), failUpdate, info.getUpdateValidationError() != null);
assertEquals(uv.getReport().getFailureMessage(), failDelete, info.getDeleteValidationError() != null);
return uv;
} catch (TeiidException e) {
throw new RuntimeException(e);
}
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestValidator method testValidateInModeler.
@Test
public void testValidateInModeler() throws Exception {
// SQL is same as pm1.vsp36() in example1
// $NON-NLS-1$
String sql = "CREATE VIRTUAL PROCEDURE BEGIN select 1, 2; END";
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
Command command = QueryParser.getQueryParser().parseCommand(sql);
GroupSymbol group = new GroupSymbol("pm1.vsp36");
QueryResolver.resolveCommand(command, group, Command.TYPE_STORED_PROCEDURE, metadata, true);
assertEquals(2, command.getResultSetColumns().size());
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestValidator method testCase4237.
/**
* Test case 4237. This test simulates the way the modeler transformation
* panel uses the query resolver and validator to validate a transformation for
* a virtual procedure. The modeler has to supply external metadata for the
* virtual procedure group and parameter names (simulated in this test).
*
* This virtual procedure calls a physical stored procedure directly.
*/
@Test
public void testCase4237() throws Exception {
QueryMetadataInterface metadata = helpCreateCase4237VirtualProcedureMetadata();
// $NON-NLS-1$
String sql = "CREATE VIRTUAL PROCEDURE BEGIN EXEC pm1.sp(vm1.sp.in1); END";
Command command = helpResolve(sql, new GroupSymbol("vm1.sp"), Command.TYPE_STORED_PROCEDURE, metadata);
helpRunValidator(command, new String[0], metadata);
}
Aggregations