use of org.teiid.query.sql.lang.SetQuery 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();
}
}
}
}
use of org.teiid.query.sql.lang.SetQuery 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);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class RelationalPlan method clone.
public RelationalPlan clone() {
RelationalPlan plan = new RelationalPlan((RelationalNode) root.clone());
plan.setOutputElements(outputCols);
if (with != null) {
List<WithQueryCommand> newWith = LanguageObject.Util.deepClone(this.with, WithQueryCommand.class);
for (WithQueryCommand withQueryCommand : newWith) {
if (withQueryCommand.isRecursive()) {
SetQuery setQuery = (SetQuery) withQueryCommand.getCommand();
setQuery.getLeftQuery().setProcessorPlan(setQuery.getLeftQuery().getProcessorPlan().clone());
setQuery.getRightQuery().setProcessorPlan(setQuery.getRightQuery().getProcessorPlan().clone());
} else {
withQueryCommand.getCommand().setProcessorPlan(withQueryCommand.getCommand().getProcessorPlan().clone());
}
}
plan.setWith(newWith);
}
return plan;
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class UpdateValidator method validate.
public void validate(Command command, List<ElementSymbol> viewSymbols) throws QueryMetadataException, TeiidComponentException {
if (this.updateInfo.deleteType != UpdateType.INHERENT && this.updateInfo.updateType != UpdateType.INHERENT && this.updateInfo.insertType != UpdateType.INHERENT) {
return;
}
if (command instanceof SetQuery) {
SetQuery setQuery = (SetQuery) command;
if (setQuery.getLimit() != null) {
// $NON-NLS-1$
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0013"), true, true, true);
return;
}
LinkedList<Query> queries = new LinkedList<Query>();
if (!PartitionAnalyzer.extractQueries((SetQuery) command, queries)) {
// $NON-NLS-1$
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0001"), true, true, true);
return;
}
Map<ElementSymbol, List<Set<Constant>>> partitions = PartitionAnalyzer.extractPartionInfo((SetQuery) command, viewSymbols);
this.updateInfo.partitionInfo = partitions;
if (partitions.isEmpty()) {
// $NON-NLS-1$
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0018"), false, true, false);
}
boolean first = true;
for (Query query : queries) {
UpdateInfo ui = this.updateInfo;
if (!first) {
this.updateInfo = new UpdateInfo();
this.updateInfo.deleteType = ui.deleteType;
this.updateInfo.insertType = ui.insertType;
this.updateInfo.updateType = ui.updateType;
}
internalValidate(query, viewSymbols);
// accumulate the errors on the first branch - will be checked at resolve time
if (this.updateInfo.getDeleteValidationError() != null) {
ui.setDeleteValidationError(this.updateInfo.getDeleteValidationError());
}
if (this.updateInfo.getUpdateValidationError() != null) {
ui.setUpdateValidationError(this.updateInfo.getUpdateValidationError());
}
if (this.updateInfo.getInsertValidationError() != null) {
ui.setInsertValidationError(this.updateInfo.getInsertValidationError());
}
if (!first) {
ui.unionBranches.add(this.updateInfo);
this.updateInfo = ui;
} else {
first = false;
}
}
return;
}
internalValidate(command, viewSymbols);
if (this.updateInfo.deleteType != UpdateType.INHERENT) {
this.deleteReport.getItems().clear();
this.updateInfo.deleteValidationError = null;
}
if (this.updateInfo.updateType != UpdateType.INHERENT) {
this.updateReport.getItems().clear();
this.updateInfo.updateValidationError = null;
}
if (this.updateInfo.insertType != UpdateType.INHERENT) {
this.insertReport.getItems().clear();
this.updateInfo.insertValidationError = null;
}
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestLimitParsing method testSetQueryLimit.
@Test
public void testSetQueryLimit() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
// $NON-NLS-1$
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
query.setSelect(select);
query.setFrom(from);
SetQuery setQuery = new SetQuery(Operation.UNION, true, query, query);
setQuery.setLimit(new Limit(new Reference(0), new Reference(1)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a union all Select * from a limit ?,?", "SELECT * FROM a UNION ALL SELECT * FROM a LIMIT ?, ?", setQuery);
}
Aggregations