Author: shawkins
Date: 2012-07-09 14:59:20 -0400 (Mon, 09 Jul 2012)
New Revision: 4227
Added:
trunk/api/src/main/java/org/teiid/translator/CacheDirective.java
Modified:
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/org/teiid/query/processor/TestArrayTable.java
trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
TEIID-2077 refining the shared state logic and pushing the common table creation into the
temptable and allowing updatable to apply to resultset caching
Added: trunk/api/src/main/java/org/teiid/translator/CacheDirective.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/CacheDirective.java
(rev 0)
+++ trunk/api/src/main/java/org/teiid/translator/CacheDirective.java 2012-07-09 18:59:20
UTC (rev 4227)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator;
+
+import java.io.Serializable;
+
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+
+public class CacheDirective implements Serializable {
+
+ public enum Scope {
+ USER,
+ SESSION,
+ VDB
+ }
+
+ private static final long serialVersionUID = -4119606289701982511L;
+
+ private Boolean prefersMemory;
+ private Boolean updatable;
+ private Long ttl;
+ private Scope scope;
+
+ public CacheDirective() {
+ }
+
+ public CacheDirective(Boolean prefersMemory, Long ttl) {
+ this.prefersMemory = prefersMemory;
+ this.ttl = ttl;
+ }
+
+ public Boolean getPrefersMemory() {
+ return prefersMemory;
+ }
+
+ public void setPrefersMemory(Boolean prefersMemory) {
+ this.prefersMemory = prefersMemory;
+ }
+
+ public Long getTtl() {
+ return ttl;
+ }
+
+ public void setTtl(Long ttl) {
+ this.ttl = ttl;
+ }
+
+ public Boolean getUpdatable() {
+ return updatable;
+ }
+
+ public void setUpdatable(Boolean updatable) {
+ this.updatable = updatable;
+ }
+
+ public Scope getScope() {
+ return this.scope;
+ }
+
+ public void setScope(Scope scope) {
+ this.scope = scope;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof CacheDirective)) {
+ return false;
+ }
+ CacheDirective other = (CacheDirective)obj;
+ return EquivalenceUtil.areEqual(this.prefersMemory, other.prefersMemory)
+ && EquivalenceUtil.areEqual(this.ttl, other.ttl)
+ && EquivalenceUtil.areEqual(this.updatable, other.updatable)
+ && EquivalenceUtil.areEqual(this.scope, other.scope);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeUtil.hashCode(1, scope, ttl, updatable);
+ }
+
+}
Property changes on: trunk/api/src/main/java/org/teiid/translator/CacheDirective.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-07-09 14:31:47 UTC
(rev 4226)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-07-09 18:59:20 UTC
(rev 4227)
@@ -50,6 +50,7 @@
<li>The standalone and cli configuration files specify a setting for the teiid
subsystem policy-decider-module. If a module is not specified, then data roles will not
be checked.
<li>local connections specifying a VDB version will wait for their VDB to finish
loading before allowing a connection.
<li>jsonToXml document elements will contain xsi:type attribute values of decimal
and boolean respectively for number and boolean json values to allow for differentiation
from string values.
+ <li>Result set cache entries can now have updatable set to false to indicate that
updates should not purge the entry.
<ul>
<h4>from 7.x</h4>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -615,11 +615,16 @@
cr.setResults(resultsBuffer, processor.getProcessorPlan());
if (originalCommand.getCacheHint() != null) {
LogManager.logDetail(LogConstants.CTX_DQP, requestID, "Using cache
hint", originalCommand.getCacheHint()); //$NON-NLS-1$
- resultsBuffer.setPrefersMemory(originalCommand.getCacheHint().getPrefersMemory());
+ resultsBuffer.setPrefersMemory(originalCommand.getCacheHint().isPrefersMemory());
if (originalCommand.getCacheHint().getDeterminism() != null) {
determinismLevel = originalCommand.getCacheHint().getDeterminism();
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Cache hint modified
the query determinism from ",processor.getContext().getDeterminismLevel(), " to
", determinismLevel }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
+ //if not updatable, then remove the access info
+ if (!originalCommand.getCacheHint().isUpdatable(true)) {
+ cr.getAccessInfo().setSensitiveToMetadataChanges(false);
+ cr.getAccessInfo().getObjectsAccessed().clear();
+ }
}
if (determinismLevel.compareTo(Determinism.SESSION_DETERMINISTIC) <= 0) {
Modified:
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -113,6 +113,33 @@
private static final Charset UTF_16LE = Charset.forName("UTF-16LE");
//$NON-NLS-1$
private static final Charset UTF_8 = Charset.forName("UTF-8"); //$NON-NLS-1$
+ private static final Location dummyLocation = new Location() {
+ @Override
+ public String getSystemId() {
+ return null;
+ }
+
+ @Override
+ public String getPublicId() {
+ return null;
+ }
+
+ @Override
+ public int getLineNumber() {
+ return -1;
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return -1;
+ }
+
+ @Override
+ public int getCharacterOffset() {
+ return -1;
+ }
+ };
+
private static final class JsonToXmlContentHandler implements
ContentHandler, XMLEventReader {
private Reader reader;
@@ -834,33 +861,7 @@
if (stream) {
//jre 1.7 event logic does not set a dummy location and throws an NPE in StAXSource,
so we explicitly set a location
- reader.eventFactory.setLocation(new Location() {
-
- @Override
- public String getSystemId() {
- return null;
- }
-
- @Override
- public String getPublicId() {
- return null;
- }
-
- @Override
- public int getLineNumber() {
- return -1;
- }
-
- @Override
- public int getColumnNumber() {
- return -1;
- }
-
- @Override
- public int getCharacterOffset() {
- return -1;
- }
- });
+ reader.eventFactory.setLocation(dummyLocation);
return new SQLXMLImpl() {
@SuppressWarnings("unchecked")
public <T extends Source> T getSource(Class<T> sourceClass) throws
SQLException {
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -58,8 +58,8 @@
public static final TempMetadataID TEMP_MODEL = new
TempMetadataID("__TEMP__", Collections.EMPTY_LIST); //$NON-NLS-1$
private TempMetadataStore tempStore;
- private Map materializationTables;
- private Map queryNodes;
+ private Map<Object, Object> materializationTables;
+ private Map<Object, QueryNode> queryNodes;
private boolean session;
public TempMetadataAdapter(QueryMetadataInterface metadata, TempMetadataStore tempStore)
{
@@ -67,7 +67,7 @@
this.tempStore = tempStore;
}
- public TempMetadataAdapter(QueryMetadataInterface metadata, TempMetadataStore
tempStore, Map materializationTables, Map queryNodes) {
+ public TempMetadataAdapter(QueryMetadataInterface metadata, TempMetadataStore
tempStore, Map<Object, Object> materializationTables, Map<Object, QueryNode>
queryNodes) {
super(metadata);
this.tempStore = tempStore;
this.materializationTables = materializationTables;
@@ -290,7 +290,7 @@
throws TeiidComponentException, QueryMetadataException {
if (this.queryNodes != null && this.queryNodes.containsKey(groupID)) {
- return (QueryNode)this.queryNodes.get(groupID);
+ return this.queryNodes.get(groupID);
}
if(groupID instanceof TempMetadataID && !(actualMetadata instanceof
TempMetadataAdapter)) {
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -38,6 +38,7 @@
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.sql.symbol.ElementSymbol.DisplayMode;
import org.teiid.query.sql.util.SymbolMap;
@@ -66,55 +67,51 @@
this.parent = parent;
}
- public String getElementName(Expression symbol, boolean renameGroup) {
- String name = null;
- if (currentSymbols != null) {
- name = currentSymbols.get(symbol);
- if (name != null) {
- if (renameGroup && symbol instanceof ElementSymbol) {
- renameGroup(((ElementSymbol)symbol).getGroupSymbol());
- }
- return name;
- }
- }
+ public String getElementName(Expression symbol) {
if (!(symbol instanceof ElementSymbol)) {
return null;
}
ElementSymbol element = (ElementSymbol)symbol;
+ String newGroupName =
this.groupNames.get(element.getGroupSymbol().getName());
+ if (newGroupName == null) {
+ if (parent == null) {
+ return null;
+ }
+ return parent.getElementName(symbol);
+ }
+ //check for inline view
Map<String, String> elements =
this.elementMap.get(element.getGroupSymbol().getName());
if (elements != null) {
- name = elements.get(element.getShortName());
+ String name = elements.get(element.getShortName());
if (name != null) {
- if (renameGroup) {
- renameGroup(element.getGroupSymbol());
- }
+ renameGroup(element.getGroupSymbol(), newGroupName);
return name;
}
}
- if (parent != null) {
- name = parent.getElementName(symbol, renameGroup);
- if (name != null) {
- return name;
- }
- }
- if (renameGroup) {
- renameGroup(element.getGroupSymbol());
- }
+ if (parent != null) {
+ String name = parent.getElementName(symbol);
+ if (name != null) {
+ return name;
+ }
+ }
+ renameGroup(element.getGroupSymbol(), newGroupName);
return null;
}
- public void renameGroup(GroupSymbol obj) {
+ public void renameGroup(GroupSymbol obj, String newAlias) {
if (aliasGroups) {
String definition = obj.getNonCorrelationName();
- String newAlias = getGroupName(obj.getName());
if (newAlias == null) {
return;
}
- obj.setOutputName(newAlias);
- obj.setOutputDefinition(definition);
+ obj.setName(newAlias);
+ obj.setDefinition(definition);
} else if(obj.getDefinition() != null) {
- obj.setOutputName(obj.getDefinition());
- obj.setOutputDefinition(null);
+ obj.setName(obj.getDefinition());
+ obj.setDefinition(null);
+ } else {
+ obj.setOutputName(null);
+ obj.setOutputDefinition(null);
}
}
@@ -146,14 +143,12 @@
if(group == null) {
return;
}
- String newName = namingContext.getElementName(obj, true);
+ String newName = namingContext.getElementName(obj);
- if (newName == null) {
- newName = Symbol.getShortName(obj.getOutputName());
+ if (newName != null) {
+ obj.setShortName(newName);
}
-
- obj.setOutputName(group.getOutputName() + Symbol.SEPARATOR + newName);
- obj.setDisplayMode(ElementSymbol.DisplayMode.OUTPUT_NAME);
+ obj.setDisplayMode(ElementSymbol.DisplayMode.FULLY_QUALIFIED);
}
/**
@@ -161,7 +156,7 @@
*/
@Override
public void visit(GroupSymbol obj) {
- this.namingContext.renameGroup(obj);
+ this.namingContext.renameGroup(obj,
this.namingContext.getGroupName(obj.getName()));
}
public void createChildNamingContext(boolean aliasColumns) {
@@ -205,12 +200,11 @@
}
public void visit(Select obj) {
- super.visit(obj);
- List<Expression> selectSymbols = obj.getSymbols();
+ List<Expression> selectSymbols = obj.getSymbols();
HashMap<Expression, String> symbols = new HashMap<Expression,
String>(selectSymbols.size());
for (int i = 0; i < selectSymbols.size(); i++) {
Expression symbol = selectSymbols.get(i);
-
+ visitNode(symbol);
boolean needsAlias = visitor.namingContext.aliasColumns;
String newAlias = "c_" + i; //$NON-NLS-1$
@@ -219,7 +213,7 @@
if (newSymbol instanceof ElementSymbol) {
if (!needsAlias) {
- newAlias = ((ElementSymbol)newSymbol).getOutputName();
+ newAlias = ((ElementSymbol)newSymbol).getShortName();
} else {
needsAlias &= needsAlias(newAlias, (ElementSymbol)newSymbol);
}
@@ -228,7 +222,7 @@
symbols.put(symbol, newAlias);
if (visitor.namingContext.aliasColumns && needsAlias) {
newSymbol = new AliasSymbol(Symbol.getShortName(symbol), newSymbol);
- ((AliasSymbol)newSymbol).setOutputName(newAlias);
+ ((AliasSymbol)newSymbol).setShortName(newAlias);
}
selectSymbols.set(i, newSymbol);
}
@@ -238,7 +232,7 @@
private boolean needsAlias(String newAlias,
ElementSymbol symbol) {
- return !(symbol.getMetadataID() instanceof TempMetadataID) ||
!newAlias.equalsIgnoreCase(visitor.namingContext.getElementName(symbol, false));
+ return !(symbol.getMetadataID() instanceof TempMetadataID) ||
!newAlias.equalsIgnoreCase(symbol.getShortName());
}
/**
@@ -265,15 +259,17 @@
}
visitor.namingContext.parent.elementMap.put(obj.getName(), viewGroup);
visitor.removeChildNamingContext();
- obj.getGroupSymbol().setOutputName(recontextGroup(obj.getGroupSymbol(), true));
+ obj.getGroupSymbol().setName(recontextGroup(obj.getGroupSymbol(), true));
}
@Override
public void visit(UnaryFromClause obj) {
+ GroupSymbol symbol = obj.getGroup();
if (visitor.aliasGroups) {
- GroupSymbol symbol = obj.getGroup();
recontextGroup(symbol, false);
- }
+ } else {
+ visitor.namingContext.groupNames.put(symbol.getName(),
symbol.getNonCorrelationName());
+ }
super.visit(obj);
}
@@ -328,11 +324,17 @@
for (int i = 0; i < obj.getVariableCount(); i++) {
OrderByItem item = obj.getOrderByItems().get(i);
Expression element = item.getSymbol();
+ visitNode(element);
if (item.isUnrelated()) {
- visitNode(element);
continue;
}
- String name = visitor.namingContext.getElementName(element, false);
+ String name = null;
+ if (visitor.namingContext.currentSymbols != null) {
+ name = visitor.namingContext.currentSymbols.get(element);
+ }
+ if (name == null) {
+ name = Symbol.getShortName(element);
+ }
boolean needsAlias = visitor.namingContext.aliasColumns;
if (name == null) {
continue;
@@ -347,11 +349,13 @@
element = new AliasSymbol(Symbol.getShortName(element), expr);
} else if (expr instanceof ElementSymbol) {
element = expr;
- visitNode(element);
+ if (visitor.namingContext.aliasColumns) {
+ ((ElementSymbol)expr).setDisplayMode(DisplayMode.SHORT_OUTPUT_NAME);
+ }
}
item.setSymbol(element);
if (element instanceof Symbol) {
- ((Symbol)element).setOutputName(name);
+ ((Symbol)element).setShortName(name);
}
}
}
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -39,6 +39,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
@@ -64,12 +65,10 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.WindowFunction;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
-import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
import org.teiid.query.sql.visitor.EvaluatableVisitor.EvaluationLevel;
@@ -79,8 +78,8 @@
private AnalysisRecord analysisRecord;
private CapabilitiesFinder capFinder;
- private Map<List<Object>, AccessNode> sharedCommands = new
HashMap<List<Object>, AccessNode>();
- private Map<List<Object>, Integer> topCount = new
HashMap<List<Object>, Integer>();
+ //state for detecting and reusing source queries
+ private Map<Command, AccessNode> sharedCommands = new HashMap<Command,
AccessNode>();
private int sharedId;
public static class SharedStateKey {
@@ -115,7 +114,6 @@
return processPlan;
} finally {
sharedCommands.clear();
- topCount.clear();
sharedId = 0;
}
}
@@ -351,43 +349,8 @@
}
setRoutingName(aNode, node);
//check if valid to share this with other nodes
- if (ev != null &&
ev.getDeterminismLevel().compareTo(Determinism.COMMAND_DETERMINISTIC) >= 0 &&
command.returnsResultSet()) {
- //create a top level key to avoid the full command toString
- String modelName = aNode.getModelName();
- Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command,
true);
- List<Object> topKey = new
ArrayList<Object>(groups.size() + 1);
- topKey.add(modelName);
- for (GroupSymbol groupSymbol : groups) {
- topKey.add(groupSymbol.toString());
- }
-
- AccessNode other = sharedCommands.get(topKey);
- if (other == null) {
- sharedCommands.put(topKey, aNode);
- topCount.put(topKey, 1);
- } else {
- int count = topCount.get(topKey);
- if (count == 1) {
- Command c = other.getCommand();
- List<Object> key = getCommandKey(c);
- sharedCommands.put(key, other);
- }
- topCount.put(topKey, ++count);
- Command c = aNode.getCommand();
- List<Object> key = getCommandKey(c);
-
- AccessNode initial = this.sharedCommands.get(key);
- if (initial != null) {
- if (initial.info == null) {
- initial.info = new
RegisterRequestParameter.SharedAccessInfo();
- initial.info.id = sharedId++;
- }
- initial.info.sharingCount++;
- aNode.info = initial.info;
- } else {
- this.sharedCommands.put(key, aNode);
- }
- }
+ if (ev != null &&
ev.getDeterminismLevel().compareTo(Determinism.COMMAND_DETERMINISTIC) >= 0 &&
command.areResultsCachable()) {
+ checkForSharedSourceCommand(aNode);
}
}
break;
@@ -550,13 +513,36 @@
return processNode;
}
-
- private List<Object> getCommandKey(Command c) {
- List<Reference> refs = ReferenceCollectorVisitor.getReferences(c);
- List<Object> key = new ArrayList<Object>(2);
- key.add(c.toString());
- key.add(refs);
- return key;
+
+ private void checkForSharedSourceCommand(AccessNode aNode) {
+ //create a top level key to avoid the full command toString
+ String modelName = aNode.getModelName();
+ Command cmd = aNode.getCommand();
+
+ //don't share full scans against internal sources, it's a waste of buffering
+ if (CoreConstants.SYSTEM_MODEL.equals(modelName)
+ || CoreConstants.SYSTEM_ADMIN_MODEL.equals(modelName)
+ || TempMetadataAdapter.TEMP_MODEL.getName().equals(modelName)) {
+ if (!(cmd instanceof Query)) {
+ return;
+ }
+ Query query = (Query)cmd;
+ if (query.getOrderBy() == null && query.getCriteria() == null) {
+ return;
+ }
+ }
+
+ AccessNode other = sharedCommands.get(cmd);
+ if (other == null) {
+ sharedCommands.put(cmd, aNode);
+ } else {
+ if (other.info == null) {
+ other.info = new RegisterRequestParameter.SharedAccessInfo();
+ other.info.id = sharedId++;
+ }
+ other.info.sharingCount++;
+ aNode.info = other.info;
+ }
}
private void updateGroupName(PlanNode node, TableFunctionReference tt) {
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -98,18 +98,20 @@
*/
private TempMetadataStore globalTempMetadata = new TempMetadataStore();
- private Map stagingTableMap = new HashMap();
+ private Map<Object, Object> stagingTableMap = new HashMap<Object,
Object>();
+ private Map<Object, QueryNode> queryNodeMap = new HashMap<Object,
QueryNode>();
- private Map queryNodeMap = new HashMap();
+ private TempMetadataAdapter tma;
// ################## Output for processing -> XMLPlan ##################
public XMLPlannerEnvironment(QueryMetadataInterface qmi) {
this.metadata = qmi;
+ this.tma = new TempMetadataAdapter(metadata, this.globalTempMetadata,
this.stagingTableMap, this.queryNodeMap);
}
TempMetadataAdapter getGlobalMetadata() {
- return new TempMetadataAdapter(metadata, this.globalTempMetadata,
this.stagingTableMap, this.queryNodeMap);
+ return tma;
}
public ResultSetInfo getStagingTableResultsInfo(String groupName) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -105,7 +105,7 @@
@Override
public void closeSource() {
- if (--state.expectedReaders == 0) {
+ if (--state.expectedReaders == 0 && sharedStates != null &&
sharedStates.containsKey(state.id)) {
state.remove();
sharedStates.remove(state.id);
}
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -22,7 +22,7 @@
package org.teiid.query.processor.relational;
-import java.util.LinkedList;
+import java.util.HashMap;
import java.util.List;
import org.teiid.client.plan.PlanNode;
@@ -34,19 +34,15 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.language.SQLConstants;
import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.metadata.TempMetadataAdapter;
-import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.QueryProcessor;
-import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.sql.LanguageObject;
-import org.teiid.query.sql.lang.Create;
-import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.lang.WithQueryCommand;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStore.TableProcessor;
import org.teiid.query.tempdata.TempTableStore.TransactionMode;
import org.teiid.query.util.CommandContext;
@@ -59,8 +55,6 @@
private List<? extends Expression> outputCols;
private List<WithQueryCommand> with;
- private List<WithQueryCommand> withToProcess;
- private QueryProcessor withProcessor;
private TempTableStore tempTableStore;
private boolean multisourceUpdate;
private SourceHint sourceHint;
@@ -104,9 +98,6 @@
tempTableStore = new TempTableStore(context.getConnectionId(),
TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
- for (WithQueryCommand withCommand : this.with) {
- withCommand.getCommand().getProcessorPlan().initialize(context, dataMgr,
bufferMgr);
- }
}
setContext(context);
connectExternal(this.root, context, dataMgr, bufferMgr);
@@ -136,34 +127,15 @@
public void open()
throws TeiidComponentException, TeiidProcessingException {
- if (this.with != null) {
- if (withToProcess == null) {
- withToProcess = new LinkedList<WithQueryCommand>(with);
- }
- while (!withToProcess.isEmpty()) {
- WithQueryCommand withCommand = withToProcess.get(0);
- if (withProcessor == null) {
- ProcessorPlan plan = withCommand.getCommand().getProcessorPlan();
- withProcessor = new QueryProcessor(plan, getContext(), this.root.getBufferManager(),
this.root.getDataManager());
- Create create = new Create();
- create.setElementSymbolsAsColumns(withCommand.getColumns());
- create.setTable(withCommand.getGroupSymbol());
- this.root.getDataManager().registerRequest(getContext(), create,
TempMetadataAdapter.TEMP_MODEL.getID(), new RegisterRequestParameter());
- }
- while (true) {
- TupleBatch batch = withProcessor.nextBatch();
- Insert insert = new Insert(withCommand.getGroupSymbol(),
withCommand.getColumns(), null);
- insert.setTupleSource(new
CollectionTupleSource(batch.getTuples().iterator()));
- this.root.getDataManager().registerRequest(getContext(), insert,
TempMetadataAdapter.TEMP_MODEL.getID(), new RegisterRequestParameter());
- if (batch.getTerminationFlag()) {
- break;
- }
- }
- this.tempTableStore.setUpdatable(withCommand.getGroupSymbol().getName(),
false);
- withToProcess.remove(0);
- withProcessor = null;
+ if (with != null) {
+ HashMap<String, TableProcessor> processors = new HashMap<String,
TableProcessor>();
+ tempTableStore.setProcessors(processors);
+ for (WithQueryCommand withCommand : this.with) {
+ ProcessorPlan plan = withCommand.getCommand().getProcessorPlan();
+ QueryProcessor withProcessor = new QueryProcessor(plan, getContext(),
root.getBufferManager(), root.getDataManager());
+ processors.put(withCommand.getGroupSymbol().getName(), new
TableProcessor(withProcessor, withCommand.getColumns()));
}
- }
+ }
this.root.open();
}
@@ -178,14 +150,15 @@
public void close()
throws TeiidComponentException {
- if (this.with != null) {
- for (WithQueryCommand withCommand : this.with) {
- withCommand.getCommand().getProcessorPlan().close();
+ if (this.tempTableStore != null) {
+ this.tempTableStore.removeTempTables();
+ if (this.tempTableStore.getProcessors() != null) {
+ for (TableProcessor proc : this.tempTableStore.getProcessors().values()) {
+ proc.getQueryProcessor().closeProcessing();
+ }
+ this.tempTableStore.setProcessors(null);
}
- if (this.tempTableStore != null) {
- this.tempTableStore.removeTempTables();
- }
- }
+ }
this.root.close();
}
@@ -197,8 +170,6 @@
this.root.reset();
if (this.with != null) {
- withToProcess = null;
- withProcessor = null;
for (WithQueryCommand withCommand : this.with) {
withCommand.getCommand().getProcessorPlan().reset();
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java 2012-07-09 14:31:47
UTC (rev 4226)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java 2012-07-09 18:59:20
UTC (rev 4227)
@@ -22,13 +22,11 @@
package org.teiid.query.sql.lang;
-import java.io.Serializable;
-
-import org.teiid.core.util.EquivalenceUtil;
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.translator.CacheDirective;
-public class CacheHint implements Serializable {
+public class CacheHint extends CacheDirective {
private static final long serialVersionUID = -4119606289701982511L;
@@ -38,39 +36,20 @@
public static final String CACHE = "cache"; //$NON-NLS-1$
public static final String SCOPE = "scope:"; //$NON-NLS-1$
- private static final String SESSION = "session"; //$NON-NLS-1$
- private static final String VDB = "vdb"; //$NON-NLS-1$
- private static final String USER = "user"; //$NON-NLS-1$
-
- private boolean prefersMemory;
- private boolean updatable;
- private Long ttl;
- private String scope;
-
public CacheHint() {
}
- public CacheHint(boolean prefersMemory, Long ttl) {
- this.prefersMemory = prefersMemory;
- this.ttl = ttl;
+ public CacheHint(Boolean prefersMemory, Long ttl) {
+ super(prefersMemory, ttl);
}
-
- public boolean getPrefersMemory() {
- return prefersMemory;
- }
- public void setPrefersMemory(boolean prefersMemory) {
- this.prefersMemory = prefersMemory;
+ public boolean isPrefersMemory() {
+ if (getPrefersMemory() != null) {
+ return getPrefersMemory();
+ }
+ return false;
}
-
- public Long getTtl() {
- return ttl;
- }
-
- public void setTtl(Long ttl) {
- this.ttl = ttl;
- }
-
+
@Override
public String toString() {
SQLStringVisitor ssv = new SQLStringVisitor();
@@ -78,52 +57,32 @@
return ssv.getSQLString();
}
- public boolean isUpdatable() {
- return updatable;
- }
-
- public void setUpdatable(boolean updatable) {
- this.updatable = updatable;
- }
-
public Determinism getDeterminism() {
- if (this.scope == null) {
+ if (this.getScope() == null) {
return null;
}
-
- if (scope.equals(SESSION)) {
+ switch (getScope()) {
+ case SESSION:
return Determinism.SESSION_DETERMINISTIC;
- }
- else if (this.scope.equals(VDB)) {
+ case VDB:
return Determinism.VDB_DETERMINISTIC;
}
- else if (this.scope.equals(USER)) {
- return Determinism.USER_DETERMINISTIC;
- }
- return null;
+ return Determinism.USER_DETERMINISTIC;
}
- public String getScope() {
- return this.scope;
- }
-
public void setScope(String scope) {
- this.scope = scope;
+ if (scope == null) {
+ setScope((Scope)null);
+ } else {
+ setScope(Scope.valueOf(scope.toUpperCase()));
+ }
}
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
+ public boolean isUpdatable(boolean b) {
+ if (getUpdatable() != null) {
+ return getUpdatable();
}
- if (!(obj instanceof CacheHint)) {
- return false;
- }
- CacheHint other = (CacheHint)obj;
- return this.prefersMemory == other.prefersMemory
- && EquivalenceUtil.areEqual(this.ttl, other.ttl)
- && this.updatable == other.updatable
- && EquivalenceUtil.areEqual(this.scope, other.scope);
+ return b;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2012-07-09 14:31:47 UTC
(rev 4226)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2012-07-09 18:59:20 UTC
(rev 4227)
@@ -425,16 +425,11 @@
if (isXML) {
return true;
}
- List projectedSymbols = getProjectedSymbols();
- return areResultsCachable(projectedSymbols);
+ List<Expression> projectedSymbols = getProjectedSymbols();
+ return areColumnsCachable(projectedSymbols);
}
- public static boolean areResultsCachable(Collection<? extends Expression>
projectedSymbols) {
- for (Expression projectedSymbol : projectedSymbols) {
- if(projectedSymbol.getType() == DataTypeManager.DefaultDataClasses.OBJECT) {
- return false;
- }
- }
+ public static boolean areColumnsCachable(Collection<? extends Expression>
projectedSymbols) {
return true;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -323,7 +323,10 @@
* @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
- return Query.areResultsCachable(getProjectedSymbols());
+ if (getUpdateCount() > 0) {
+ return false;
+ }
+ return Query.areColumnsCachable(getProjectedSymbols());
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -98,9 +98,8 @@
UnaryFromClause other = (UnaryFromClause)obj;
- if( (this.getGroup().getDefinition() == null &&
other.getGroup().getDefinition() == null) ||
- (this.getGroup().getDefinition() != null &&
other.getGroup().getDefinition() != null) ) {
- return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) &&
+ if( EquivalenceUtil.areEqual(group.getDefinition(),
other.getGroup().getDefinition()) ) {
+ return EquivalenceUtil.areEqual(getGroup().getNonCorrelationName(),
other.getGroup().getNonCorrelationName()) &&
other.isOptional() == this.isOptional();
}
return false;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateProcedureCommand.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -239,7 +239,7 @@
* @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
- return Query.areResultsCachable(getProjectedSymbols());
+ return Query.areColumnsCachable(getProjectedSymbols());
}
public GroupSymbol getVirtualGroup() {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -971,7 +971,7 @@
append(SPACE);
append(CacheHint.CACHE);
boolean addParens = false;
- if (obj.getPrefersMemory()) {
+ if (obj.isPrefersMemory()) {
append(Tokens.LPAREN);
addParens = true;
append(CacheHint.PREF_MEM);
@@ -986,7 +986,7 @@
append(CacheHint.TTL);
append(obj.getTtl());
}
- if (obj.isUpdatable()) {
+ if (obj.getUpdatable() != null) {
if (!addParens) {
append(Tokens.LPAREN);
addParens = true;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -334,12 +334,12 @@
table.setUpdatable(false);
CacheHint hint = table.getCacheHint();
if (hint != null) {
- table.setPreferMemory(hint.getPrefersMemory());
+ table.setPreferMemory(hint.isPrefersMemory());
if (hint.getTtl() != null) {
getMatTableInfo(tableName).setTtl(hint.getTtl());
}
if (pk != null) {
- table.setUpdatable(hint.isUpdatable());
+ table.setUpdatable(hint.isUpdatable(false));
}
}
return table;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -70,13 +70,11 @@
import org.teiid.query.processor.RegisterRequestParameter;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.sql.lang.*;
-import org.teiid.query.sql.navigator.PostOrderNavigator;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.Reference;
-import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
import org.teiid.query.tempdata.GlobalTableStoreImpl.MatTableInfo;
import org.teiid.query.util.CommandContext;
@@ -366,28 +364,6 @@
return null;
}
final String tableName = group.getNonCorrelationName();
- if (!tableName.equalsIgnoreCase(group.getName())) {
- group = group.clone();
- group.setName(tableName);
- group.setDefinition(null);
- query.getFrom().getClauses().clear();
- query.getFrom().addClause(new UnaryFromClause(group));
- final GroupSymbol newGroup = group;
- //convert to the actual table symbols (this is typically handled by the
languagebridgefactory
- ExpressionMappingVisitor emv = new ExpressionMappingVisitor(null) {
- @Override
- public Expression replaceExpression(Expression element) {
- if (element instanceof ElementSymbol) {
- ElementSymbol es = (ElementSymbol)element;
- es = es.clone();
- es.setGroupSymbol(newGroup);
- return es;
- }
- return element;
- }
- };
- PostOrderNavigator.doVisit(query, emv);
- }
TempTable table = null;
if (group.isGlobalTable()) {
final GlobalTableStore globalStore = context.getGlobalTableStore();
@@ -485,7 +461,7 @@
}
CacheHint hint = table.getCacheHint();
if (hint != null && table.getPkLength() > 0) {
- table.setUpdatable(hint.isUpdatable());
+ table.setUpdatable(hint.isUpdatable(false));
}
} catch (TeiidComponentException e) {
LogManager.logError(LogConstants.CTX_MATVIEWS, e,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30015, tableName));
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -24,6 +24,7 @@
import java.sql.Connection;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -37,7 +38,9 @@
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.api.exception.query.QueryProcessingException;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
@@ -48,6 +51,8 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.QueryProcessor;
import org.teiid.query.resolver.command.TempTableResolver;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Create;
@@ -80,6 +85,21 @@
NONE
}
+ public static class TableProcessor {
+ QueryProcessor queryProcessor;
+ List<ElementSymbol> columns;
+
+ public TableProcessor(QueryProcessor queryProcessor,
+ List<ElementSymbol> columns) {
+ this.queryProcessor = queryProcessor;
+ this.columns = columns;
+ }
+
+ public QueryProcessor getQueryProcessor() {
+ return queryProcessor;
+ }
+ }
+
public class TempTableSynchronization implements Synchronization {
private String id;
@@ -181,6 +201,8 @@
private String sessionID;
private TempTableStore parentTempTableStore;
+ private HashMap<String, TableProcessor> processors;
+
public TempTableStore(String sessionID, TransactionMode transactionMode) {
this.sessionID = sessionID;
this.transactionMode = transactionMode;
@@ -193,6 +215,10 @@
public boolean hasTempTable(String tempTableName) {
return tempTables.containsKey(tempTableName);
}
+
+ public void setProcessors(HashMap<String, TableProcessor> plans) {
+ this.processors = plans;
+ }
TempTable addTempTable(final String tempTableName, Create create, BufferManager
buffer, boolean add, CommandContext context) throws TeiidProcessingException {
List<ElementSymbol> columns = create.getColumnSymbols();
@@ -285,9 +311,19 @@
return this.tempTables.get(tempTableID);
}
- TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager
buffer, boolean delegate, boolean forUpdate, CommandContext context) throws
TeiidProcessingException{
+ public HashMap<String, TableProcessor> getProcessors() {
+ return processors;
+ }
+
+ TempTable getOrCreateTempTable(String tempTableID, Command command, BufferManager
buffer, boolean delegate, boolean forUpdate, CommandContext context) throws
TeiidProcessingException, BlockedException, TeiidComponentException{
TempTable tempTable = getTempTable(tempTableID, command, buffer, delegate,
forUpdate, context);
if (tempTable != null) {
+ if (processors != null) {
+ TableProcessor withProcessor = processors.get(tempTableID);
+ if (withProcessor != null) {
+ buildWithTable(tempTableID, withProcessor, tempTable);
+ }
+ }
return tempTable;
}
//allow implicit temp group definition
@@ -300,6 +336,18 @@
}
}
if (columns == null) {
+ if (processors != null) {
+ TableProcessor withProcessor = processors.get(tempTableID);
+ if (withProcessor != null) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Creating temporary
table for with clause", tempTableID); //$NON-NLS-1$
+ Create create = new Create();
+ create.setTable(new GroupSymbol(tempTableID));
+ create.setElementSymbolsAsColumns(withProcessor.columns);
+ tempTable = addTempTable(tempTableID, create, buffer, true, context);
+ buildWithTable(tempTableID, withProcessor, tempTable);
+ return tempTable;
+ }
+ }
throw new QueryProcessingException(QueryPlugin.Event.TEIID30226,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30226, tempTableID));
}
LogManager.logDetail(LogConstants.CTX_DQP, "Creating temporary table",
tempTableID); //$NON-NLS-1$
@@ -309,6 +357,15 @@
return addTempTable(tempTableID, create, buffer, true, context);
}
+ private void buildWithTable(String tempTableID,
+ TableProcessor withProcessor, TempTable tempTable)
+ throws TeiidComponentException, ExpressionEvaluationException,
+ TeiidProcessingException {
+ tempTable.insert(new BatchIterator(withProcessor.queryProcessor),
withProcessor.columns, false);
+ tempTable.setUpdatable(false);
+ processors.remove(tempTableID);
+ }
+
private TempTable getTempTable(String tempTableID, Command command,
BufferManager buffer, boolean delegate, boolean forUpdate, CommandContext context)
throws TeiidProcessingException {
Modified: trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2012-07-09 14:31:47 UTC
(rev 4226)
+++ trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2012-07-09 18:59:20 UTC
(rev 4227)
@@ -72,6 +72,7 @@
command = QueryRewriter.rewrite(command, metadata, null);
expandAllSymbol(command);
if (generateAliases) {
+ command = (Command)command.clone();
command.acceptVisitor(new AliasGenerator(supportsGroupAlias));
}
return new LanguageBridgeFactory(metadata).translate(command);
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -105,7 +105,7 @@
String sql = "SELECT a12.intkey, MAX(a12.stringkey),
MIN(a11.intnum+a12.intnum) FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON
a11.stringkey = a12.stringkey GROUP BY a12.intkey"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.stringkey,
g_0.intkey, g_0.intnum FROM BQT2.SmallA AS g_0 GROUP BY g_0.stringkey, g_0.intkey,
g_0.intnum", "SELECT g_0.stringkey, g_0.intnum FROM BQT1.SmallA AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.StringKey,
g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS g_0 GROUP BY g_0.StringKey, g_0.IntKey,
g_0.IntNum", "SELECT g_0.StringKey, g_0.IntNum FROM BQT1.SmallA AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -136,7 +136,7 @@
String sql = "SELECT a12.intkey, MAX(a12.stringkey),
SUM(a11.intnum+a12.intnum) FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON
a11.stringkey = a12.stringkey GROUP BY a12.intkey"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.stringkey,
g_0.intkey, g_0.intnum FROM BQT2.SmallA AS g_0", "SELECT g_0.stringkey,
g_0.intnum FROM BQT1.SmallA AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.StringKey,
g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS g_0", "SELECT g_0.StringKey,
g_0.IntNum FROM BQT1.SmallA AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -203,7 +203,7 @@
String sql = "select sum(a11.intnum) Profit, (sum(a11.intnum) /
sum(a11.floatnum)) WJXBFS2 from bqt1.smalla a11 join bqt2.smallb a12 on
a11.intkey=a12.intkey group by a12.intkey"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.intkey,
SUM(g_0.intnum), SUM(g_0.floatnum) FROM BQT1.SmallA AS g_0 GROUP BY g_0.intkey",
"SELECT g_0.intkey FROM BQT2.SmallB AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.IntKey FROM
BQT2.SmallB AS g_0", "SELECT g_0.IntKey, SUM(g_0.IntNum), SUM(g_0.FloatNum) FROM
BQT1.SmallA AS g_0 GROUP BY g_0.IntKey"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -235,7 +235,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
null, getAggregatesFinder(),
- new String[] {"SELECT g_0.p_productid AS c_0
FROM m2.product AS g_0 WHERE g_0.p_divid = 100 ORDER BY c_0", "SELECT
g_0.o_productid, g_0.o_dealerid, SUM(g_0.o_amount) FROM m1.\"order\" AS g_0,
m1.dealer AS g_1 WHERE (g_0.o_dealerid = g_1.d_dealerid) AND (g_1.d_state = 'CA')
AND (g_0.o_productid IN (<dependent values>)) GROUP BY g_0.o_productid,
g_0.o_dealerid"}, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.O_ProductID,
g_0.O_DealerID, SUM(g_0.O_Amount) FROM m1.\"order\" AS g_0, m1.dealer AS g_1
WHERE (g_0.O_DealerID = g_1.D_DealerID) AND (g_1.D_State = 'CA') AND
(g_0.O_ProductID IN (<dependent values>)) GROUP BY g_0.O_ProductID,
g_0.O_DealerID", "SELECT g_0.P_ProductID AS c_0 FROM m2.product AS g_0 WHERE
g_0.P_DivID = 100 ORDER BY c_0"}, //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -265,7 +265,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
metadata,
null, getAggregatesFinder(),
- new String[] {"SELECT g_0.p_productid AS c_0
FROM m2.product AS g_0 WHERE g_0.p_divid = 100 ORDER BY c_0", "SELECT
g_0.o_productid, g_0.o_dealerid, MAX(g_0.o_amount), SUM(g_0.o_amount) FROM
m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.o_dealerid = g_1.d_dealerid)
AND (g_1.d_state = 'CA') AND (g_0.o_productid IN (<dependent values>)) GROUP
BY g_0.o_productid, g_0.o_dealerid"}, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.P_ProductID AS c_0
FROM m2.product AS g_0 WHERE g_0.P_DivID = 100 ORDER BY c_0", "SELECT
g_0.O_ProductID, g_0.O_DealerID, MAX(g_0.O_Amount), SUM(g_0.O_Amount) FROM
m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.O_DealerID = g_1.D_DealerID)
AND (g_1.D_State = 'CA') AND (g_0.O_ProductID IN (<dependent values>)) GROUP
BY g_0.O_ProductID, g_0.O_DealerID"}, //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -520,7 +520,7 @@
String sql = "select a11.intkey ITEM_ID, sum(a11.intnum) WJXBFS1 from
bqt1.smalla a11 join bqt2.smalla a12 on (a11.stringkey = a12.stringkey) join bqt2.smallb
a13 on (a11.intkey = a13.intkey) where a13.intnum in (10) group by a11.intkey";
//$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.stringkey,
g_0.intkey, SUM(g_0.intnum) FROM BQT1.SmallA AS g_0 GROUP BY g_0.stringkey,
g_0.intkey", "SELECT g_0.stringkey FROM BQT2.SmallA AS g_0", "SELECT
g_0.intkey FROM BQT2.SmallB AS g_0 WHERE g_0.intnum = 10"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ new String[] {"SELECT g_0.IntKey FROM
BQT2.SmallB AS g_0 WHERE g_0.IntNum = 10", "SELECT g_0.StringKey FROM
BQT2.SmallA AS g_0", "SELECT g_0.StringKey, g_0.IntKey, SUM(g_0.IntNum) FROM
BQT1.SmallA AS g_0 GROUP BY g_0.StringKey, g_0.IntKey"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
TestOptimizer.checkNodeTypes(plan, new int[] {
3, // Access
@@ -573,7 +573,7 @@
"select stringkey, max(intkey) from bqt1.smalla group by stringkey
having count(intkey) = 1", //$NON-NLS-1$
metadata, null, capFinder,
new String[] {
- "SELECT COUNT(g_0.intkey), g_0.stringkey, MAX(g_0.intkey) FROM
BQT1.SmallA AS g_0 GROUP BY g_0.stringkey"}, //$NON-NLS-1$
+ "SELECT COUNT(g_0.IntKey), g_0.StringKey, MAX(g_0.IntKey) FROM
BQT1.SmallA AS g_0 GROUP BY g_0.StringKey"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -81,7 +81,7 @@
Command depCommand = accessNode.getCommand();
Collection<GroupSymbol> groupSymbols =
GroupCollectorVisitor.getGroups(depCommand, true);
for (GroupSymbol groupSymbol : groupSymbols) {
- depGroups.add(groupSymbol.getName().toUpperCase());
+ depGroups.add(groupSymbol.getNonCorrelationName().toUpperCase());
}
}
@@ -713,7 +713,7 @@
"SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM
(SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp,
BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT g_0.StringKey FROM BQT1.SmallA AS g_0 WHERE
g_0.StringKey IN (<dependent values>)", "SELECT g_0.STRINGKEY,
g_0.STRINGNUM, g_0.IntKey FROM BQT2.SmallA AS g_0"}, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.StringKey, g_0.StringNum, g_0.IntKey FROM
BQT2.SmallA AS g_0", "SELECT g_0.StringKey FROM BQT1.SmallA AS g_0 WHERE
g_0.StringKey IN (<dependent values>)"}, //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -757,7 +757,7 @@
"SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM
(SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp,
BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey AND table1comp.key1 =
BQT1.SmallA.StringNum", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT g_0.STRINGKEY, g_0.STRINGNUM, g_0.IntKey FROM
BQT2.SmallA AS g_0", "SELECT g_0.StringKey, g_0.StringNum FROM BQT1.SmallA AS
g_0 WHERE (g_0.StringNum = g_0.StringKey) AND (g_0.StringKey IN (<dependent
values>)) AND (g_0.StringNum IN (<dependent values>))"}, //$NON-NLS-1$
//$NON-NLS-2$
+ new String[] {"SELECT g_0.StringKey, g_0.StringNum, g_0.IntKey FROM
BQT2.SmallA AS g_0", "SELECT g_0.StringKey, g_0.StringNum FROM BQT1.SmallA AS
g_0 WHERE (g_0.StringNum = g_0.StringKey) AND (g_0.StringKey IN (<dependent
values>)) AND (g_0.StringNum IN (<dependent values>))"}, //$NON-NLS-1$
//$NON-NLS-2$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
TestOptimizer.checkNodeTypes(plan, new int[] {
@@ -802,7 +802,7 @@
"SELECT max(a.stringkey) from bqt1.smalla a, bqt2.smalla a2, bqt1.smalla
a1 where a.intnum = a2.intnum and a1.stringnum = a2.stringnum and a.floatnum =
a1.floatnum", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT g_1.stringnum AS c_0, g_0.intnum AS c_1,
MAX(g_0.stringkey) AS c_2 FROM BQT1.SmallA AS g_0, BQT1.SmallA AS g_1 WHERE g_0.floatnum =
g_1.floatnum GROUP BY g_1.stringnum, g_0.intnum ORDER BY c_0, c_1", "SELECT
DISTINCT g_0.stringnum AS c_0, g_0.intnum AS c_1 FROM BQT2.SmallA AS g_0 WHERE
(g_0.stringnum IN (<dependent values>)) AND (g_0.intnum IN (<dependent
values>)) ORDER BY c_0, c_1"},
+ new String[] {"SELECT DISTINCT g_0.StringNum AS c_0, g_0.IntNum AS c_1
FROM BQT2.SmallA AS g_0 WHERE (g_0.StringNum IN (<dependent values>)) AND
(g_0.IntNum IN (<dependent values>)) ORDER BY c_0, c_1", "SELECT
g_1.StringNum AS c_0, g_0.IntNum AS c_1, MAX(g_0.StringKey) AS c_2 FROM BQT1.SmallA AS
g_0, BQT1.SmallA AS g_1 WHERE g_0.FloatNum = g_1.FloatNum GROUP BY g_1.StringNum,
g_0.IntNum ORDER BY c_0, c_1"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
TestOptimizer.checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -31,6 +31,8 @@
import java.util.Set;
import org.junit.Test;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -93,7 +95,7 @@
public static InlineViewCase createANSIJoinInlineView() throws Exception {
String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a,
bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join
bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.intkey) AS c_0 FROM
BQT1.SmallA AS g_0 WHERE g_0.intkey = 1 GROUP BY g_0.intkey) AS v_0 LEFT OUTER JOIN
BQT1.SmallB AS g_1 ON v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.IntKey) AS c_0 FROM
BQT1.SmallA AS g_0 WHERE g_0.IntKey = 1 GROUP BY g_0.IntKey) AS v_0 LEFT OUTER JOIN
BQT1.SmallB AS g_1 ON v_0.c_0 = g_1.IntKey"; //$NON-NLS-1$
List<List<?>> expectedResults = new ArrayList<List<?>>();
expectedResults.add(Arrays.asList(1));
@@ -113,7 +115,7 @@
public static InlineViewCase createInlineView() throws Exception {
String userQuery = "select
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
from (select count(bqt1.smalla.intkey) as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey)
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
bqt1.smallb " + //$NON-NLS-1$
"where
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.intkey
= 1 and
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
= bqt1.smallb.intkey"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.intkey) AS c_0 FROM
BQT1.SmallA AS g_0 WHERE g_0.intkey = 1 GROUP BY g_0.intkey) AS v_0, BQT1.SmallB AS g_1
WHERE v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.IntKey) AS c_0 FROM
BQT1.SmallA AS g_0 WHERE g_0.IntKey = 1 GROUP BY g_0.IntKey) AS v_0, BQT1.SmallB AS g_1
WHERE v_0.c_0 = g_1.IntKey"; //$NON-NLS-1$
List<List<?>> expectedResults = new ArrayList<List<?>>();
expectedResults.add(Arrays.asList(1));
@@ -131,7 +133,7 @@
public static InlineViewCase createInlineViewWithDistinctAndOrderBy() throws Exception
{
String userQuery = "select Q1.a from (select distinct count(bqt1.smalla.intkey) as
a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by
bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a =
1 and q1.a + q1.intkey = 2"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.intkey AS c_0,
COUNT(g_0.intkey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.intkey HAVING
(COUNT(g_0.intkey) = 1) AND ((COUNT(g_0.intkey) + g_0.intkey) = 2)) AS v_0, BQT1.SmallB AS
g_1 WHERE v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.IntKey AS c_0,
COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey HAVING
(COUNT(g_0.IntKey) = 1) AND ((COUNT(g_0.IntKey) + g_0.IntKey) = 2)) AS v_0, BQT1.SmallB AS
g_1 WHERE v_0.c_0 = g_1.IntKey"; //$NON-NLS-1$
List<List<?>> expectedResults = new
ArrayList<List<?>>();
expectedResults.add(Arrays.asList(1));
@@ -167,7 +169,7 @@
public static InlineViewCase createInlineViewWithOuterOrderAndGroup() throws Exception
{
String userQuery = "select count(Q1.a) b from (select distinct
count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on
q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by
b"; //$NON-NLS-1$
- String optimizedQuery = "SELECT COUNT(v_0.c_1) AS c_0 FROM (SELECT g_0.intkey AS
c_0, COUNT(g_0.intkey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.intkey HAVING
(COUNT(g_0.intkey) = 1) AND ((COUNT(g_0.intkey) + g_0.intkey) = 2)) AS v_0, BQT1.SmallB AS
g_1 WHERE v_0.c_0 = g_1.intkey GROUP BY v_0.c_1 ORDER BY c_0"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT COUNT(v_0.c_1) AS c_0 FROM (SELECT g_0.IntKey AS
c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey HAVING
(COUNT(g_0.IntKey) = 1) AND ((COUNT(g_0.IntKey) + g_0.IntKey) = 2)) AS v_0, BQT1.SmallB AS
g_1 WHERE v_0.c_0 = g_1.IntKey GROUP BY v_0.c_1 ORDER BY c_0"; //$NON-NLS-1$
List<List<?>> expectedResults = new ArrayList<List<?>>();
expectedResults.add(Arrays.asList(1));
@@ -185,7 +187,7 @@
public static InlineViewCase crateInlineViewsInUnions() throws Exception {
String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a,
bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join
bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a)
b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from
bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join
bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group
by Q1.a order by b)"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM
BQT1.SmallA AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN
BQT1.SmallB AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_1) AS c_0 FROM
(SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY
g_0.IntKey HAVING (COUNT(g_0.IntKey) = 1) AND ((COUNT(g_0.IntKey) + g_0.IntKey) = 2)) AS
v_0, BQT1.SmallB AS g_1 WHERE v_0.c_0 = g_1.intkey GROUP BY v_0.c_1"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.IntKey) AS c_0 FROM
BQT1.SmallA AS g_2 WHERE g_2.IntKey = 1 GROUP BY g_2.IntKey) AS v_1 LEFT OUTER JOIN
BQT1.SmallB AS g_3 ON v_1.c_0 = g_3.IntKey UNION ALL SELECT COUNT(v_0.c_1) AS c_0 FROM
(SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY
g_0.IntKey HAVING (COUNT(g_0.IntKey) = 1) AND ((COUNT(g_0.IntKey) + g_0.IntKey) = 2)) AS
v_0, BQT1.SmallB AS g_1 WHERE v_0.c_0 = g_1.IntKey GROUP BY v_0.c_1"; //$NON-NLS-1$
List<List<?>> expectedResults = new ArrayList<List<?>>();
expectedResults.add(Arrays.asList(1));
@@ -206,7 +208,7 @@
public static InlineViewCase createUnionInInlineView() throws Exception{
String userQuery = "select t1.intkey from (select case when q1.a=1 then 2 else
1 end as a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from
bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a =
bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select
distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on
q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b))
as q3, bqt1.smallb as t1 where q3.a = t1.intkey order by t1.intkey"; //$NON-NLS-1$
- String optimizedQuery = "SELECT g_4.intkey AS c_0 FROM (SELECT CASE WHEN v_1.c_0 =
1 THEN 2 ELSE 1 END AS c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM BQT1.SmallA AS g_2
WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN BQT1.SmallB AS g_3 ON
v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_1) AS c_0 FROM (SELECT g_0.IntKey AS
c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey HAVING
(COUNT(g_0.IntKey) = 1) AND ((COUNT(g_0.IntKey) + g_0.IntKey) = 2)) AS v_0, BQT1.SmallB AS
g_1 WHERE v_0.c_0 = g_1.intkey GROUP BY v_0.c_1) AS v_2, BQT1.SmallB AS g_4 WHERE v_2.c_0
= g_4.intkey ORDER BY c_0"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT g_4.IntKey AS c_0 FROM (SELECT CASE WHEN v_1.c_0 =
1 THEN 2 ELSE 1 END AS c_0 FROM (SELECT COUNT(g_2.IntKey) AS c_0 FROM BQT1.SmallA AS g_2
WHERE g_2.IntKey = 1 GROUP BY g_2.IntKey) AS v_1 LEFT OUTER JOIN BQT1.SmallB AS g_3 ON
v_1.c_0 = g_3.IntKey UNION ALL SELECT COUNT(v_0.c_1) AS c_0 FROM (SELECT g_0.IntKey AS
c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey HAVING
(COUNT(g_0.IntKey) = 1) AND ((COUNT(g_0.IntKey) + g_0.IntKey) = 2)) AS v_0, BQT1.SmallB AS
g_1 WHERE v_0.c_0 = g_1.IntKey GROUP BY v_0.c_1) AS v_2, BQT1.SmallB AS g_4 WHERE v_2.c_0
= g_4.IntKey ORDER BY c_0"; //$NON-NLS-1$
List<List<?>> expectedResults = new ArrayList<List<?>>();
expectedResults.add(Arrays.asList(1));
@@ -236,22 +238,22 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- @Test public void testAliasCreationWithInlineView() {
+ @Test public void testAliasCreationWithInlineView() throws TeiidComponentException,
TeiidProcessingException {
FakeCapabilitiesFinder capFinder = getInliveViewCapabilitiesFinder();
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan("select a, b from (select distinct
count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by
bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT COUNT(g_0.intNum)
AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey ORDER BY c_0"},
true); //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT COUNT(g_0.IntNum)
AS c_0, g_0.IntKey AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey ORDER BY c_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
- @Test public void testAliasPreservationWithInlineView() {
+ @Test public void testAliasPreservationWithInlineView() throws
TeiidComponentException, TeiidProcessingException {
FakeCapabilitiesFinder capFinder = getInliveViewCapabilitiesFinder();
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select
count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by
bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b
FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla
GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS
q1"}, true); //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT (v_0.c_0 + 1),
v_0.c_1 FROM (SELECT COUNT(g_0.IntNum) AS c_0, g_0.IntKey AS c_1 FROM BQT1.SmallA AS g_0
GROUP BY g_0.IntNum, g_0.IntKey HAVING COUNT(g_0.IntNum) = 1) AS v_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
@@ -264,8 +266,8 @@
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan("select * from (select
count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a,
bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey =
q2.intkey where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1
FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY
g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0",
- "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey)
AS c_1 FROM BQT2.SmallB AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1
FROM (SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT2.SmallB AS g_0 GROUP BY
g_0.IntKey) AS v_0 ORDER BY c_0",
+ "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey)
AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey HAVING COUNT(g_0.IntKey) = 1) AS v_0
ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
2, // Access
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -295,7 +295,7 @@
String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join
(select bqt3.smalla.intkey from bqt3.smalla where bqt3.smalla.intkey = 1) foo on
bqt1.smalla.intkey = foo.intkey"; //$NON-NLS-1$
// Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), new String[] {"SELECT 1 FROM BQT3.SmallA AS
g_0 WHERE g_0.intkey = 1", "SELECT g_0.intkey FROM BQT1.SmallA AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.IntKey FROM
BQT1.SmallA AS g_0", "SELECT 1 FROM BQT3.SmallA AS g_0 WHERE g_0.IntKey =
1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -426,7 +426,7 @@
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT
g_3.intkey, g_0.intkey FROM ((BQT1.SmallB AS g_0 CROSS JOIN BQT1.MediumA AS g_1) INNER
JOIN BQT1.MediumB AS g_2 ON ((g_0.intkey + g_1.intkey) + g_2.intkey) = 1) LEFT OUTER JOIN
BQT1.SmallA AS g_3 ON g_3.stringkey = g_0.stringkey"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ new String[] {"SELECT
g_3.IntKey, g_0.IntKey FROM ((BQT1.SmallB AS g_0 CROSS JOIN BQT1.MediumA AS g_1) INNER
JOIN BQT1.MediumB AS g_2 ON ((g_0.IntKey + g_1.IntKey) + g_2.IntKey) = 1) LEFT OUTER JOIN
BQT1.SmallA AS g_3 ON g_3.StringKey = g_0.StringKey"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
@@ -517,7 +517,7 @@
String sql = "select b.intkey from (select intkey from bqt1.smalla) a left
outer join (select intkey from bqt1.smallb) b on (1 = 1)"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- new String[]{"SELECT g_1.intkey
FROM BQT1.SmallA AS g_0 LEFT OUTER JOIN BQT1.SmallB AS g_1 ON 1 = 1"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ new String[]{"SELECT g_1.IntKey
FROM BQT1.SmallA AS g_0 LEFT OUTER JOIN BQT1.SmallB AS g_1 ON 1 = 1"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
@@ -1041,9 +1041,9 @@
"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallB, BQT1.Smalla, bqt2.smallb
where bqt2.smallb.intkey = bqt1.smallb.intkey and bqt2.smallb.stringkey =
bqt1.smalla.stringkey", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT g_0.stringkey AS c_0, g_0.intkey AS c_1 FROM
BQT2.SmallB AS g_0 ORDER BY c_0",
- "SELECT g_0.stringkey AS c_0, g_0.IntKey AS c_1 FROM BQT1.SmallA AS
g_0 ORDER BY c_0",
- "SELECT g_0.intkey AS c_0 FROM BQT1.SmallB AS g_0 ORDER BY c_0"},
//$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT g_0.StringKey AS c_0, g_0.IntKey AS c_1 FROM
BQT2.SmallB AS g_0 ORDER BY c_0",
+ "SELECT g_0.StringKey AS c_0, g_0.IntKey AS c_1 FROM BQT1.SmallA AS
g_0 ORDER BY c_0",
+ "SELECT g_0.IntKey AS c_0 FROM BQT1.SmallB AS g_0 ORDER BY c_0"},
ComparisonMode.EXACT_COMMAND_STRING );
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -530,7 +530,7 @@
String sql = "SELECT * FROM pm1.g1 UNION ALL SELECT * FROM PM1.g2 LIMIT 50,
100";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT PM1.g2.e1 AS c_0, PM1.g2.e2 AS c_1, PM1.g2.e3 AS c_2, PM1.g2.e4
AS c_3 FROM PM1.g2 LIMIT 150", "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1,
pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT 150" //$NON-NLS-1$
//$NON-NLS-2$
+ "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4
AS c_3 FROM pm1.g1 LIMIT 150", "SELECT pm1.g2.e1 AS c_0, pm1.g2.e2 AS c_1,
pm1.g2.e3 AS c_2, pm1.g2.e4 AS c_3 FROM pm1.g2 LIMIT 150" //$NON-NLS-1$
//$NON-NLS-2$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.example1Cached(),
null, capFinder, expectedSql,
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -2110,7 +2110,7 @@
"SELECT MAX(sa.datevalue) FROM bqt1.smalla AS sb " + //$NON-NLS-1$
"WHERE (sb.intkey = sa.intkey) AND (sa.stringkey = sb.stringkey)
))"; //$NON-NLS-1$
- String sqlOut = "SELECT g_0.intkey FROM BQT1.SmallA AS g_0 WHERE (g_0.intkey
= 46) AND (g_0.stringkey = '46') AND (g_0.datevalue = (SELECT MAX(g_0.datevalue)
FROM BQT1.SmallA AS g_1 WHERE (g_1.intkey = g_0.intkey) AND (g_1.stringkey =
g_0.stringkey)))"; //$NON-NLS-1$
+ String sqlOut = "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE (g_0.IntKey
= 46) AND (g_0.StringKey = '46') AND (g_0.DateValue = (SELECT MAX(g_0.DateValue)
FROM BQT1.SmallA AS g_1 WHERE (g_1.IntKey = g_0.IntKey) AND (g_1.StringKey =
g_0.StringKey)))"; //$NON-NLS-1$
ProcessorPlan plan = helpPlan(sqlIn,
RealMetadataFactory.exampleBQTCached(),
@@ -4272,7 +4272,7 @@
ProcessorPlan plan = helpPlan(sql,
RealMetadataFactory.exampleBQTCached(),
null, capFinder,
- new String[] {"SELECT g_1.longnum,
g_2.datevalue, g_0.IntKEy, g_1.IntKEy, g_2.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS
g_1, BQT1.MediumA AS g_2 WHERE (g_0.StringKey = g_1.StringKey) AND (g_2.IntKey =
g_0.IntKey) AND (convert(g_0.IntNum, long) > (SELECT SUM(g_3.IntNum) FROM BQT1.SmallA
AS g_3))"}, //$NON-NLS-1$
+ new String[] {"SELECT g_1.LongNum,
g_2.DateValue, g_0.IntKey, g_1.IntKey, g_2.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS
g_1, BQT1.MediumA AS g_2 WHERE (g_0.StringKey = g_1.StringKey) AND (g_2.IntKey =
g_0.IntKey) AND (convert(g_0.IntNum, long) > (SELECT SUM(g_3.IntNum) FROM BQT1.SmallA
AS g_3))"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, new int[] {
@@ -4496,7 +4496,7 @@
ProcessorPlan plan = helpPlan(sql,
RealMetadataFactory.exampleBQTCached(),
null, capFinder,
- new String[] {"SELECT g_2.intkey AS c_0,
'a' AS c_1 FROM BQT1.SmallA AS g_2 UNION ALL SELECT g_1.IntKey AS c_0, 'b'
AS c_1 FROM BQT1.SmallA AS g_1 UNION ALL SELECT g_0.IntKey AS c_0, 'c' AS c_1 FROM
BQT1.SmallA AS g_0"}, //$NON-NLS-1$
+ new String[] {"SELECT g_2.IntKey AS c_0,
'a' AS c_1 FROM BQT1.SmallA AS g_2 UNION ALL SELECT g_1.IntKey AS c_0, 'b'
AS c_1 FROM BQT1.SmallA AS g_1 UNION ALL SELECT g_0.IntKey AS c_0, 'c' AS c_1 FROM
BQT1.SmallA AS g_0"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -4542,7 +4542,7 @@
Set<String> actualQueries = getAtomicQueries(subplan);
// Compare atomic queries
- HashSet<String> expectedQueries = new
HashSet<String>(Arrays.asList(new String[] { "SELECT BQT1.SmallA.datevalue FROM
BQT1.SmallA WHERE (BQT1.SmallA.intkey = BQT1.SmallA.intkey) AND (BQT1.SmallA.stringkey =
BQT1.SmallA.stringkey)"})); //$NON-NLS-1$
+ HashSet<String> expectedQueries = new
HashSet<String>(Arrays.asList(new String[] { "SELECT BQT1.SmallA.DateValue FROM
BQT1.SmallA WHERE (BQT1.SmallA.IntKey = sa.IntKey) AND (BQT1.SmallA.StringKey =
sa.StringKey)"})); //$NON-NLS-1$
assertEquals("Did not get expected atomic queries for subplan: ",
expectedQueries, actualQueries); //$NON-NLS-1$
checkNodeTypes(subplan, new int[] {
@@ -5280,7 +5280,7 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_0.intkey FROM
BQT1.SmallA AS g_0 ORDER BY g_0.intkey"}, //$NON-NLS-1$
+ new String[] {"SELECT g_0.IntKey FROM
BQT1.SmallA AS g_0 ORDER BY g_0.IntKey"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -5400,7 +5400,7 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_2.intkey FROM
((BQT1.SmallA AS g_0 CROSS JOIN BQT1.SmallA AS g_1) CROSS JOIN BQT1.MediumA AS g_2) LEFT
OUTER JOIN BQT1.MediumB AS g_3 ON g_2.intkey = g_3.intkey"}, //$NON-NLS-1$
+ new String[] {"SELECT g_2.IntKey FROM
((BQT1.SmallA AS g_0 CROSS JOIN BQT1.SmallA AS g_1) CROSS JOIN BQT1.MediumA AS g_2) LEFT
OUTER JOIN BQT1.MediumB AS g_3 ON g_2.IntKey = g_3.IntKey"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -5496,8 +5496,8 @@
null,
capFinder,
new String[] {
- "SELECT bqt2.smallb.intkey, bqt2.smalla.intkey FROM
bqt2.smalla, bqt2.smallb WHERE bqt2.smalla.stringkey = bqt2.smallb.stringkey ORDER BY
bqt2.smallb.intkey, bqt2.smalla.intkey", //$NON-NLS-1$
- "SELECT bqt1.smalla.intkey FROM bqt1.smalla ORDER BY
bqt1.smalla.intkey"}, //$NON-NLS-1$
+ "SELECT BQT2.SmallB.IntKey, BQT2.SmallA.IntKey FROM
BQT2.SmallA, BQT2.SmallB WHERE BQT2.SmallA.StringKey = BQT2.SmallB.StringKey ORDER BY
BQT2.SmallB.IntKey, BQT2.SmallA.IntKey",
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA ORDER BY
BQT1.SmallA.IntKey"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
}
@@ -5542,7 +5542,7 @@
helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_0.intkey, g_1.IntKey
FROM BQT2.SmallA AS g_0, BQT2.SmallA AS g_1 WHERE g_0.intkey = g_1.IntKey"},
//$NON-NLS-1$
+ new String[] {"SELECT g_0.IntKey, g_1.IntKey
FROM BQT2.SmallA AS g_0, BQT2.SmallA AS g_1 WHERE g_0.IntKey = g_1.IntKey"},
//$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
}
@@ -5594,7 +5594,7 @@
String sql = "SELECT env('soap_host') AS HOST, intkey from
bqt2.smalla"; //$NON-NLS-1$
helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(),
- new String[] {"SELECT bqt2.smalla.intkey FROM
bqt2.smalla"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ new String[] {"SELECT BQT2.SmallA.IntKey FROM
BQT2.SmallA"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
}
/**
@@ -5606,8 +5606,8 @@
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(),
new String[] {
- "SELECT g_0.intkey FROM BQT1.SmallA AS g_0
WHERE g_0.IntKey <> 1", //$NON-NLS-1$
- "SELECT g_0.intkey FROM BQT1.SmallA AS g_0
WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0
WHERE g_0.IntKey <> 1",
+ "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0
WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
2, // Access
@@ -5637,7 +5637,7 @@
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(),
new String[] {
- "SELECT g_0.intkey FROM BQT1.SmallA AS g_0
WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0
WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
2, // Access
@@ -6546,7 +6546,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT intkey from bqt1.smalla
where intkey = intnum", //$NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(caps),
new String[] {
- "SELECT bqt1.smalla.intkey,
bqt1.smalla.intnum FROM bqt1.smalla"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey,
BQT1.SmallA.IntNum FROM BQT1.SmallA"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
checkNodeTypes(plan, new int[] {
1, // Access
@@ -6614,7 +6614,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT stringkey from
bqt1.smalla where formattimestamp(timestampvalue, 'yyyy') = '1921' and
parsebigdecimal(stringkey, '$') = 1 and formattimestamp(timestampvalue,
'yy') = '19'", //$NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(caps),
new String[] {
- "SELECT g_0.timestampvalue, g_0.stringkey
FROM BQT1.SmallA AS g_0 WHERE (formattimestamp(g_0.timestampvalue, 'yyyy') =
'1921') AND (parsebigdecimal(g_0.stringkey, '$') = 1)"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ "SELECT g_0.TimestampValue, g_0.StringKey
FROM BQT1.SmallA AS g_0 WHERE (formattimestamp(g_0.TimestampValue, 'yyyy') =
'1921') AND (parsebigdecimal(g_0.StringKey, '$') = 1)"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
1, // Access
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -352,7 +352,7 @@
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
null, capFinder,
- new String[] { "SELECT v_0.c_0 FROM (SELECT convert(g_0.TimestampValue,
date) AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE g_0.stringkey =
g_1.stringkey) AS v_0 GROUP BY v_0.c_0" }, //$NON-NLS-1$
+ new String[] { "SELECT v_0.c_0 FROM (SELECT convert(g_0.TimestampValue,
date) AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1 WHERE g_0.StringKey =
g_1.StringKey) AS v_0 GROUP BY v_0.c_0" }, //$NON-NLS-1$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -164,7 +164,7 @@
String sql = "select b.intkey, b.x from (select intkey, intnum as x from
bqt1.smalla where 1 = 0 union all select 1 as z, intkey as b from bqt1.smallb) b inner
join bqt1.smalla on b.intkey = bqt1.smalla.intkey"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT g_0.intkey
FROM BQT1.SmallB AS g_0, BQT1.SmallA AS g_1 WHERE g_1.IntKey = 1"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ new String[]{"SELECT g_0.IntKey
FROM BQT1.SmallB AS g_0, BQT1.SmallA AS g_1 WHERE g_1.IntKey = 1"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -1036,7 +1036,7 @@
BasicSourceCapabilities bsc = getTypicalCapabilities();
bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[]
{"SELECT g_0.shortvalue, g_0.intnum, g_0.intkey FROM BQT1.SmallA AS g_0"}, new
DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), new String[]
{"SELECT g_0.ShortValue, g_0.IntNum, g_0.IntKey FROM BQT1.SmallA AS g_0"}, new
DefaultCapabilitiesFinder(bsc), ComparisonMode.EXACT_COMMAND_STRING);
}
@Test public void testInvalidGeneratedSemijoinQuery1() throws Exception {
@@ -1086,7 +1086,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT 1 FROM bqt1.smalla as
Y93 INNER JOIN bqt1.smallb as AG5 ON 1 = 1 WHERE EXISTS (SELECT 'Y' FROM
bqt1.mediuma WHERE AG5.intkey = 1 AND Y93.intkey = 1 )", //$NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(bsc),
new String[] {
- "SELECT 1 FROM BQT1.SmallA AS g_0 CROSS
JOIN BQT1.SmallB AS g_1 WHERE EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_2 WHERE
(g_1.intkey = 1) AND (g_0.intkey = 1))"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
+ "SELECT 1 FROM BQT1.SmallA AS g_0 CROSS
JOIN BQT1.SmallB AS g_1 WHERE EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_2 WHERE
(g_1.IntKey = 1) AND (g_0.IntKey = 1))"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
}
@@ -1104,7 +1104,7 @@
TestOptimizer.helpPlan("SELECT 1 FROM bqt1.smalla as Y93 LEFT OUTER JOIN
bqt1.smallb as AG5 ON EXISTS (SELECT 'Y' FROM bqt1.mediuma WHERE AG5.intkey = 1
AND Y93.intkey = 1 )", //$NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(bsc),
new String[] {
- "SELECT g_0.intkey FROM BQT1.SmallA AS
g_0", "SELECT g_0.intkey FROM BQT1.SmallB AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ "SELECT g_0.IntKey FROM BQT1.SmallA AS
g_0", "SELECT g_0.IntKey FROM BQT1.SmallB AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
}
/**
@@ -1122,7 +1122,7 @@
TestOptimizer.helpPlan("SELECT 1 FROM bqt1.smalla as Y93 LEFT OUTER JOIN
bqt1.smallb as AG5 ON EXISTS (SELECT 'Y' FROM bqt1.mediuma WHERE AG5.intkey = 1
AND Y93.intkey = 1 )", //$NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), null, new
DefaultCapabilitiesFinder(bsc),
new String[] {
- "SELECT 1 FROM BQT1.SmallA AS g_0 LEFT
OUTER JOIN BQT1.SmallB AS g_1 ON EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_2 WHERE
(g_1.intkey = 1) AND (g_0.intkey = 1))"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
+ "SELECT 1 FROM BQT1.SmallA AS g_0 LEFT
OUTER JOIN BQT1.SmallB AS g_1 ON EXISTS (SELECT 'Y' FROM BQT1.MediumA AS g_2 WHERE
(g_1.IntKey = 1) AND (g_0.IntKey = 1))"}, ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -188,8 +188,8 @@
@Test public void testUnionPushDownWithJoin1() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT IntKey
FROM BQT1.SmallA where intkey in (1, 2) UNION ALL SELECT intkey FROM BQT2.SmallA where
intkey in (3, 4)) A inner join (SELECT intkey FROM BQT1.SmallB where intkey in (1, 2)
UNION ALL SELECT intkey FROM BQT2.SmallB where intkey in (3, 4)) B on a.intkey = b.intkey
where a.intkey in (1, 4)", RealMetadataFactory.exampleBQTCached(), null,
TestOptimizer.getGenericFinder(),//$NON-NLS-1$
- new String[] { "SELECT g_1.intkey, g_0.IntKey FROM BQT1.SmallA AS g_0,
BQT1.SmallB AS g_1 WHERE (g_0.IntKey = g_1.intkey) AND (g_0.intkey IN (1)) AND (g_0.IntKey
= 1) AND (g_1.intkey = 1)",
- "SELECT g_1.intkey, g_0.intkey FROM BQT2.SmallA AS g_0, BQT2.SmallB AS
g_1 WHERE (g_0.intkey = g_1.intkey) AND (g_0.intkey IN (4)) AND (g_0.intkey = 4) AND
(g_1.intkey = 4)" }, ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT g_1.IntKey, g_0.IntKey FROM BQT1.SmallA AS g_0,
BQT1.SmallB AS g_1 WHERE (g_0.IntKey = g_1.IntKey) AND (g_0.IntKey IN (1)) AND (g_0.IntKey
= 1) AND (g_1.IntKey = 1)"
+ , "SELECT g_1.IntKey, g_0.IntKey FROM BQT2.SmallA AS g_0, BQT2.SmallB AS
g_1 WHERE (g_0.IntKey = g_1.IntKey) AND (g_0.IntKey IN (4)) AND (g_0.IntKey = 4) AND
(g_1.IntKey = 4)" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -211,7 +211,7 @@
@Test public void testUnionWithPartitionedAggregate() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select max(intnum) from (SELECT
IntKey, intnum FROM BQT1.SmallA where intkey in (1, 2) UNION ALL SELECT intkey, intnum
FROM BQT2.SmallA where intkey in (3, 4)) A group by intkey",
RealMetadataFactory.exampleBQTCached(), null,
TestInlineView.getInliveViewCapabilitiesFinder(),//$NON-NLS-1$
- new String[] { "SELECT MAX(g_0.intnum) FROM BQT2.SmallA AS g_0 WHERE
g_0.intkey IN (3, 4) GROUP BY g_0.intkey", "SELECT MAX(g_0.intnum) FROM
BQT1.SmallA AS g_0 WHERE g_0.intkey IN (1, 2) GROUP BY g_0.IntKey" },
ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT MAX(g_0.IntNum) FROM BQT1.SmallA AS g_0 WHERE
g_0.IntKey IN (1, 2) GROUP BY g_0.IntKey", "SELECT MAX(g_0.IntNum) FROM
BQT2.SmallA AS g_0 WHERE g_0.IntKey IN (3, 4) GROUP BY g_0.IntKey" },
ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -233,7 +233,7 @@
@Test public void testUnionWithUnnecessaryGroupBy() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select intkey from (SELECT
IntKey, intnum FROM BQT1.SmallA UNION ALL SELECT intkey, intnum FROM BQT2.SmallA) A group
by intkey", RealMetadataFactory.exampleBQTCached(), null,
TestInlineView.getInliveViewCapabilitiesFinder(),//$NON-NLS-1$
- new String[] { "SELECT g_0.intkey FROM BQT2.SmallA AS g_0",
"SELECT g_0.IntKey FROM BQT1.SmallA AS g_0" },
ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0",
"SELECT g_0.IntKey FROM BQT2.SmallA AS g_0" },
ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
@@ -281,10 +281,10 @@
@Test public void testUnionPartitionedWithMerge() throws Exception {
//"select max(intnum) from (select * from (SELECT IntKey, intnum FROM
BQT1.SmallA where intkey in (1, 2) UNION ALL SELECT intkey, intnum FROM BQT2.SmallA where
intkey in (3, 4)) A where intkey in (1, 2, 3, 4) UNION ALL select intkey, intnum from
bqt2.smallb where intkey in 6) B group by intkey"
ProcessorPlan plan = TestOptimizer.helpPlan("select * from (select * from
(SELECT IntKey, intnum FROM BQT1.SmallA UNION ALL SELECT intkey, intnum FROM BQT2.SmallA)
A where intkey in (1, 2, 3, 4) UNION ALL select intkey, intnum from bqt2.smallb where
intkey in (6)) B inner join (SELECT IntKey, intnum FROM BQT1.SmallA where intkey in (1, 2)
UNION ALL SELECT intkey, intnum FROM BQT2.SmallA where intkey in (5, 6)) C on b.intkey =
c.intkey", RealMetadataFactory.exampleBQTCached(), null,
TestInlineView.getInliveViewCapabilitiesFinder(),//$NON-NLS-1$
- new String[] { "SELECT g_0.intkey, g_0.intnum FROM BQT2.SmallA AS g_0
WHERE g_0.intkey IN (1, 2)",
- "SELECT g_0.IntKey, g_0.intnum FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN
(1, 2)",
- "SELECT g_1.IntKey, g_1.IntNum, g_0.intkey, g_0.intnum FROM BQT2.SmallB AS
g_0, BQT2.SmallA AS g_1 WHERE (g_0.intkey = g_1.IntKey) AND (g_0.intkey = 6) AND
(g_1.IntKey = 6)",
- "SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM BQT1.SmallA AS g_0 WHERE
g_0.IntKey IN (1, 2) ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM
BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (1, 2) ORDER BY c_0",
+ "SELECT g_0.IntKey, g_0.IntNum FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN
(1, 2)",
+ "SELECT g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS g_0 WHERE g_0.IntKey IN
(1, 2)",
+ "SELECT g_1.IntKey, g_1.IntNum, g_0.IntKey, g_0.IntNum FROM BQT2.SmallB AS
g_0, BQT2.SmallA AS g_1 WHERE (g_0.IntKey = g_1.IntKey) AND (g_0.IntKey = 6) AND
(g_1.IntKey = 6)" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
4, // Access
@@ -336,7 +336,7 @@
@Test public void testUnionPartitionedDistinct() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select distinct * from (SELECT
1 as IntKey, intnum FROM BQT1.SmallA UNION ALL SELECT 2 as intkey, intnum FROM
BQT2.SmallA) A", RealMetadataFactory.exampleBQTCached(), null,
TestInlineView.getInliveViewCapabilitiesFinder(),//$NON-NLS-1$
- new String[] { "SELECT DISTINCT g_0.intnum FROM BQT2.SmallA AS
g_0", "SELECT DISTINCT g_0.intnum FROM BQT1.SmallA AS g_0" },
ComparisonMode.EXACT_COMMAND_STRING);
+ new String[] { "SELECT DISTINCT g_0.IntNum FROM BQT2.SmallA AS
g_0", "SELECT DISTINCT g_0.IntNum FROM BQT1.SmallA AS g_0" },
ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
Modified:
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -48,6 +48,7 @@
boolean stripColumnAliases, QueryMetadataInterface metadata)
throws TeiidComponentException, TeiidProcessingException {
Command command = TestResolver.helpResolve(sql, metadata);
command = QueryRewriter.rewrite(command, metadata, null);
+ command = (Command) command.clone();
command.acceptVisitor(new AliasGenerator(aliasGroups, stripColumnAliases));
assertEquals(expected, command.toString());
return command;
@@ -74,19 +75,19 @@
String sql = "select e1 from pm1.g1 order by e1"; //$NON-NLS-1$
String expected = "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY
c_0"; //$NON-NLS-1$
Query command = (Query)helpTest(sql, expected, true, false,
RealMetadataFactory.example1Cached());
- assertEquals(((Symbol)command.getOrderBy().getSortKeys().get(0)).getName(),
"e1"); //$NON-NLS-1$
- assertEquals(((Symbol)command.getProjectedSymbols().get(0)).getShortName(),
"e1"); //$NON-NLS-1$
+ assertEquals(((Symbol)command.getOrderBy().getSortKeys().get(0)).getName(),
"c_0"); //$NON-NLS-1$
+ assertEquals(((Symbol)command.getProjectedSymbols().get(0)).getShortName(),
"c_0"); //$NON-NLS-1$
}
@Test public void testInlineViewWithSubQuery() throws Exception {
String sql = "select intnum from (select intnum from bqt1.smallb where
intnum in (select intnum a from bqt1.smalla)) b"; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM
BQT1.SmallB AS g_0 WHERE g_0.intnum IN (SELECT g_1.intnum FROM BQT1.SmallA AS g_1)) AS
v_0"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0 FROM (SELECT g_0.IntNum AS c_0 FROM
BQT1.SmallB AS g_0 WHERE g_0.IntNum IN (SELECT g_1.IntNum FROM BQT1.SmallA AS g_1)) AS
v_0"; //$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@Test public void testInlineViewOrderBy() throws Exception {
String sql = "select intnum from (select intnum from bqt1.smallb) b order by
b.intnum"; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM
BQT1.SmallB AS g_0) AS v_0 ORDER BY c_0"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0 FROM (SELECT g_0.IntNum AS c_0 FROM
BQT1.SmallB AS g_0) AS v_0 ORDER BY c_0"; //$NON-NLS-1$
Command command = helpTest(sql, expected, true, false,
RealMetadataFactory.exampleBQTCached());
LanguageBridgeFactory lbf = new
LanguageBridgeFactory(RealMetadataFactory.exampleBQTCached());
org.teiid.language.Command c = lbf.translate(command);
@@ -95,13 +96,13 @@
@Test public void testNestedInlineViewOrderBy() throws Exception {
String sql = "select x from (select intnum x from (select intnum from
bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
- String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT
g_0.intnum AS c_0 FROM BQT1.SmallB AS g_0) AS v_0) AS v_1 ORDER BY c_0";
//$NON-NLS-1$
+ String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT
g_0.IntNum AS c_0 FROM BQT1.SmallB AS g_0) AS v_0) AS v_1 ORDER BY c_0";
//$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@Test public void testInlineViewWithOnClause() throws Exception {
String sql = "select abcd.efg from (select intkey as efg from bqt1.smalla)
abcd inner join (select intnum from bqt1.smallb) b on (b.intnum = abcd.efg)";
//$NON-NLS-1$
- String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intkey AS c_0 FROM
BQT1.SmallA AS g_0) AS v_0 INNER JOIN (SELECT g_1.intnum AS c_0 FROM BQT1.SmallB AS g_1)
AS v_1 ON v_1.c_0 = v_0.c_0"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0 FROM (SELECT g_0.IntKey AS c_0 FROM
BQT1.SmallA AS g_0) AS v_0 INNER JOIN (SELECT g_1.IntNum AS c_0 FROM BQT1.SmallB AS g_1)
AS v_1 ON v_1.c_0 = v_0.c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@@ -119,19 +120,19 @@
@Test public void testCorrelatedRefernce() throws Exception {
String sql = "select intnum, stringnum from (select intnum, stringnum from
bqt1.smallb) b where intnum in (select b.stringnum || b.intnum from (select intnum from
bqt1.smalla) b) "; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0,
g_0.stringnum AS c_1 FROM BQT1.SmallB AS g_0) AS v_0 WHERE convert(v_0.c_0, string) IN
(SELECT concat(v_0.c_1, convert(v_1.c_0, string)) FROM (SELECT g_1.intnum AS c_0 FROM
BQT1.SmallA AS g_1) AS v_1)"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.IntNum AS c_0,
g_0.StringNum AS c_1 FROM BQT1.SmallB AS g_0) AS v_0 WHERE convert(v_0.c_0, string) IN
(SELECT concat(v_0.c_1, convert(v_1.c_0, string)) FROM (SELECT g_1.IntNum AS c_0 FROM
BQT1.SmallA AS g_1) AS v_1)"; //$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@Test public void testCorrelatedRefernce1() throws Exception {
String sql = "select intnum, stringnum from bqt1.smallb where intnum in (select
stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
- String expected = "SELECT g_0.intnum, g_0.stringnum FROM BQT1.SmallB AS g_0
WHERE convert(g_0.intnum, string) IN (SELECT concat(g_0.stringnum, convert(v_0.c_0,
string)) FROM (SELECT g_1.intnum AS c_0 FROM BQT1.SmallA AS g_1) AS v_0)";
//$NON-NLS-1$
+ String expected = "SELECT g_0.IntNum, g_0.StringNum FROM BQT1.SmallB AS g_0
WHERE convert(g_0.IntNum, string) IN (SELECT concat(g_0.StringNum, convert(v_0.c_0,
string)) FROM (SELECT g_1.IntNum AS c_0 FROM BQT1.SmallA AS g_1) AS v_0)";
//$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@Test public void testGroupAliasNotSupported() throws Exception {
String sql = "select b.intkey from bqt1.smalla b"; //$NON-NLS-1$
- String expected = "SELECT BQT1.SmallA.intkey FROM BQT1.SmallA";
//$NON-NLS-1$
+ String expected = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA";
//$NON-NLS-1$
helpTest(sql, expected, false, false, RealMetadataFactory.exampleBQTCached());
}
@@ -149,25 +150,25 @@
@Test public void testUnrelatedOrderBy1() throws Exception {
String sql = "SELECT b.IntKey FROM (select intkey, stringkey from BQT1.SmallA)
a, (select intkey, stringkey from BQT1.SmallA) b ORDER BY a.StringKey";
//$NON-NLS-1$
- String expected = "SELECT v_1.c_0 FROM (SELECT g_0.intkey AS c_0,
g_0.stringkey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.intkey AS c_0,
g_1.stringkey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY v_0.c_1";
//$NON-NLS-1$
+ String expected = "SELECT v_1.c_0 FROM (SELECT g_0.IntKey AS c_0,
g_0.StringKey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.IntKey AS c_0,
g_1.StringKey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY v_0.c_1";
//$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@Test public void testUnrelatedOrderBy2() throws Exception {
String sql = "SELECT b.IntKey FROM (select intkey, stringkey from BQT1.SmallA)
a, (select intkey, stringkey from BQT1.SmallA) b ORDER BY a.StringKey || b.intKey";
//$NON-NLS-1$
- String expected = "SELECT v_1.c_0 FROM (SELECT g_0.intkey AS c_0,
g_0.stringkey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.intkey AS c_0,
g_1.stringkey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY (v_0.c_1 || v_1.c_0)";
//$NON-NLS-1$
+ String expected = "SELECT v_1.c_0 FROM (SELECT g_0.IntKey AS c_0,
g_0.StringKey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.IntKey AS c_0,
g_1.StringKey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY (v_0.c_1 || v_1.c_0)";
//$NON-NLS-1$
helpTest(sql, expected, true, false, RealMetadataFactory.exampleBQTCached());
}
@Test public void testStripAliases() throws Exception {
String sql = "select intkey as a, stringkey as b from BQT1.SmallA ORDER BY a,
b"; //$NON-NLS-1$
- String expected = "SELECT g_0.intkey, g_0.stringkey FROM BQT1.SmallA AS g_0
ORDER BY g_0.intkey, g_0.stringkey"; //$NON-NLS-1$
+ String expected = "SELECT g_0.IntKey, g_0.StringKey FROM BQT1.SmallA AS g_0
ORDER BY g_0.IntKey, g_0.StringKey"; //$NON-NLS-1$
helpTest(sql, expected, true, true, RealMetadataFactory.exampleBQTCached());
}
@Test public void testStripAliases1() throws Exception {
String sql = "select intkey as a, stringkey as b from BQT1.SmallA ORDER BY a,
b"; //$NON-NLS-1$
- String expected = "SELECT BQT1.SmallA.intkey, BQT1.SmallA.stringkey FROM
BQT1.SmallA ORDER BY BQT1.SmallA.intkey, BQT1.SmallA.stringkey"; //$NON-NLS-1$
+ String expected = "SELECT BQT1.SmallA.IntKey, BQT1.SmallA.StringKey FROM
BQT1.SmallA ORDER BY BQT1.SmallA.IntKey, BQT1.SmallA.StringKey"; //$NON-NLS-1$
Command command = helpTest(sql, expected, false, true,
RealMetadataFactory.exampleBQTCached());
LanguageBridgeFactory lbf = new
LanguageBridgeFactory(RealMetadataFactory.exampleBQTCached());
org.teiid.language.Command c = lbf.translate(command);
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -40,6 +40,7 @@
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.MultipleElementSymbol;
import org.teiid.query.sql.symbol.Reference;
+import org.teiid.translator.CacheDirective.Scope;
@SuppressWarnings("nls")
public class TestOptionsAndHints {
@@ -966,10 +967,10 @@
ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
query.setFrom(from);
CacheHint hint = new CacheHint();
- hint.setScope("session");
+ hint.setScope(Scope.SESSION);
hint.setPrefersMemory(true);
query.setCacheHint(hint);
- TestParser.helpTest(sql, "/*+ cache(pref_mem scope:session) */ SELECT * FROM
t1", query); //$NON-NLS-1$
+ TestParser.helpTest(sql, "/*+ cache(pref_mem scope:SESSION) */ SELECT * FROM
t1", query); //$NON-NLS-1$
}
@Test public void testCache1() {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestArrayTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestArrayTable.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestArrayTable.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -75,7 +75,7 @@
public static void process(String sql, List[] expectedResults) throws Exception {
HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT bqt1.smalla.objectvalue FROM bqt1.smalla", new
List[] {Collections.singletonList(new Object[] {"a", 1, 2}),
Collections.singletonList(new Object[] {"b", 3, 6}),
Collections.singletonList(null)} );
+ dataManager.addData("SELECT BQT1.SmallA.ObjectValue FROM BQT1.SmallA", new
List[] {Collections.singletonList(new Object[] {"a", 1, 2}),
Collections.singletonList(new Object[] {"b", 3, 6}),
Collections.singletonList(null)} );
ProcessorPlan plan = helpGetPlan(helpParse(sql),
RealMetadataFactory.exampleBQTCached());
helpProcess(plan, createCommandContext(), dataManager, expectedResults);
}
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestCommonTableOptimizations.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.List;
+import org.junit.Ignore;
import org.junit.Test;
import org.teiid.query.unittest.RealMetadataFactory;
@@ -52,5 +53,25 @@
helpProcess(plan, dataManager, expected);
assertEquals(3, dataManager.getCommandHistory().size());
}
+
+ @Ignore
+ @Test public void testDuplicateSimpleQuery() {
+ String sql = "SELECT e1 FROM pm1.g1 union all select e2 from pm1.g1";
//$NON-NLS-1$
+ List<?>[] expected = new List[] {
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("b"), //$NON-NLS-1$
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("b"), //$NON-NLS-1$
+ };
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT pm1.g1.e1 FROM pm1.g1", new List<?>[]
{Arrays.asList("a"), Arrays.asList("b")});
+
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ assertEquals(3, dataManager.getCommandHistory().size());
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -531,10 +531,10 @@
});
HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.stringkey FROM BQT1.SmallB AS g_0",
//$NON-NLS-1$
+ dataManager.addData("SELECT g_0.StringKey FROM BQT1.SmallB AS g_0",
//$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { "1t" }),
//$NON-NLS-1$
Arrays.asList(new Object[] { "2" })});
//$NON-NLS-1$
- dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM BQT1.SmallA AS
g_0", //$NON-NLS-1$
+ dataManager.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS
g_0", //$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { "1", 1
})}); //$NON-NLS-1$
@@ -568,7 +568,7 @@
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT
g_0.stringkey, g_0.intkey FROM BQT1.SmallA AS g_0 WHERE g_0.intkey IN (<dependent
values>)", "SELECT g_0.stringkey, g_0.intkey FROM BQT2.SmallB AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"SELECT
g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey IN (<dependent
values>)", "SELECT g_0.StringKey, g_0.IntKey FROM BQT2.SmallB AS g_0"},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
1, // Access
@@ -588,10 +588,10 @@
});
HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM BQT2.SmallB AS
g_0", //$NON-NLS-1$
+ dataManager.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT2.SmallB AS
g_0", //$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { "1t", 1
}), //$NON-NLS-1$
Arrays.asList(new Object[] { "2t", 2
})}); //$NON-NLS-1$
- dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM BQT1.SmallA AS
g_0 WHERE g_0.intkey IN (1, 2)", //$NON-NLS-1$
+ dataManager.addData("SELECT g_0.StringKey, g_0.IntKey FROM BQT1.SmallA AS
g_0 WHERE g_0.IntKey IN (1, 2)", //$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { "1", 1
})}); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -68,9 +68,9 @@
globalStore = new GlobalTableStoreImpl(bm, actualMetadata);
metadata = new TempMetadataAdapter(actualMetadata, tempStore.getMetadataStore());
hdm = new HardcodedDataManager();
- hdm.addData("SELECT matsrc.x FROM matsrc", new List[]
{Arrays.asList((String)null), Arrays.asList("one"),
Arrays.asList("two"), Arrays.asList("three")});
- hdm.addData("SELECT MATTABLE.INFO.E1, MATTABLE.INFO.E2 FROM MATTABLE.INFO",
new List[] {Arrays.asList("a", 1), Arrays.asList("a", 2)});
- hdm.addData("SELECT MATTABLE.INFO.E2, MATTABLE.INFO.E1 FROM MATTABLE.INFO",
new List[] {Arrays.asList(1, "a"), Arrays.asList(2, "a")});
+ hdm.addData("SELECT MatSrc.MatSrc.x FROM MatSrc.MatSrc", new List[]
{Arrays.asList((String)null), Arrays.asList("one"),
Arrays.asList("two"), Arrays.asList("three")});
+ hdm.addData("SELECT MatTable.info.e1, MatTable.info.e2 FROM MatTable.info",
new List[] {Arrays.asList("a", 1), Arrays.asList("a", 2)});
+ hdm.addData("SELECT MatTable.info.e2, MatTable.info.e1 FROM MatTable.info",
new List[] {Arrays.asList(1, "a"), Arrays.asList(2, "a")});
SessionAwareCache<CachedResults> cache = new
SessionAwareCache<CachedResults>();
cache.setTupleBufferCache(bm);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2012-07-09
14:31:47 UTC (rev 4226)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -5759,9 +5759,9 @@
"WHERE SMALLA.INTKEY = SMALLB.INTKEY AND SMALLA.INTKEY =
MEDIUMA.INTKEY) AS X " + //$NON-NLS-1$
"WHERE X.NEWFIELD = -3"; //$NON-NLS-1$
- String expectedAtomic1 = "SELECT BQT1.SMALLB.INTKEY, BQT1.SMALLB.INTNUM FROM
BQT1.SMALLB"; //$NON-NLS-1$
- String expectedAtomic2 = "SELECT BQT1.MEDIUMA.INTKEY FROM
BQT1.MEDIUMA"; //$NON-NLS-1$
- String expectedAtomic3 = "SELECT BQT1.SMALLA.INTKEY, BQT1.SMALLA.STRINGNUM
FROM BQT1.SMALLA"; //$NON-NLS-1$
+ String expectedAtomic1 = "SELECT BQT1.SmallB.IntKey, BQT1.SmallB.IntNum FROM
BQT1.SmallB"; //$NON-NLS-1$
+ String expectedAtomic2 = "SELECT BQT1.MediumA.IntKey FROM
BQT1.MediumA"; //$NON-NLS-1$
+ String expectedAtomic3 = "SELECT BQT1.SmallA.IntKey, BQT1.SmallA.StringNum
FROM BQT1.SmallA"; //$NON-NLS-1$
// Plan query
@@ -5853,14 +5853,14 @@
Arrays.asList(new Object[] { "2", new Integer(2), new Integer(6)
}), //$NON-NLS-1$
Arrays.asList(new Object[] { "3", new Integer(3), new Integer(7)
}), //$NON-NLS-1$
};
- dataManager.addData("SELECT BQT1.SmallA.stringkey, BQT1.SmallA.intkey,
BQT1.SmallA.intnum FROM BQT1.SmallA", data1); //$NON-NLS-1$
+ dataManager.addData("SELECT BQT1.SmallA.StringKey, BQT1.SmallA.IntKey,
BQT1.SmallA.IntNum FROM BQT1.SmallA", data1); //$NON-NLS-1$
List[] data2 = new List[] {
Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
Arrays.asList(new Object[] { "3" }), //$NON-NLS-1$
};
- dataManager.addData("SELECT BQT2.MediumB.stringkey FROM BQT2.MediumB",
data2); //$NON-NLS-1$
+ dataManager.addData("SELECT BQT2.MediumB.StringKey FROM BQT2.MediumB",
data2); //$NON-NLS-1$
// Run query
List[] expectedResults = new List[] {
@@ -6245,9 +6245,9 @@
// Construct data manager with data
HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.intkey, g_0.intnum FROM BQT2.SmallA AS
g_0", //$NON-NLS-1$
+ dataManager.addData("SELECT g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS
g_0", //$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { new Integer(1), new
Integer(1) })});
- dataManager.addData("SELECT g_1.intnum AS c_0, 1 AS c_1 FROM BQT1.SmallA AS
g_1 UNION ALL SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM BQT1.SmallA AS g_0",
//$NON-NLS-1$
+ dataManager.addData("SELECT g_1.IntNum AS c_0, 1 AS c_1 FROM BQT1.SmallA AS
g_1 UNION ALL SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM BQT1.SmallA AS g_0",
//$NON-NLS-1$
new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1)
}),
Arrays.asList(new Object[] { new Integer(1), new
Integer(1) })});
helpProcess(plan, dataManager, expected);
@@ -7083,7 +7083,7 @@
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.exampleBQTCached(),
- new String[] {"SELECT b.intkey
FROM bqt2.SMALLA AS b", "SELECT a.intkey FROM bqt1.smalla AS a"}, new
DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
//$NON-NLS-2$
+ new String[] {"SELECT b.IntKey
FROM bqt2.SMALLA AS b", "SELECT a.IntKey FROM bqt1.smalla AS a"}, new
DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
//$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -42,8 +42,8 @@
import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.core.types.DataTypeManager.DefaultDataTypes;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.metadata.*;
import org.teiid.metadata.BaseColumn.NullType;
-import org.teiid.metadata.*;
import org.teiid.metadata.Column.SearchType;
import org.teiid.metadata.ProcedureParameter.Type;
import org.teiid.metadata.Table.TriggerEvent;
@@ -51,7 +51,14 @@
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.mapping.relational.QueryNode;
-import org.teiid.query.mapping.xml.*;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingOutputter;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
@@ -364,7 +371,7 @@
Table physGroup_virtSrc = createPhysicalGroup("MatSrc",
physModel_virtSrc); //$NON-NLS-1$
createElements(physGroup_virtSrc,
- new String[] { "X" }, //$NON-NLS-1$
+ new String[] { "x" }, //$NON-NLS-1$
new String[] {
DataTypeManager.DefaultDataTypes.STRING});
QueryNode virtTrans = new QueryNode("SELECT x as e1 FROM
MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
Modified:
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -63,7 +63,7 @@
Arrays.asList(new Object[] { new Double(3459808.0), new
BigDecimal("405838.6989"), TimestampUtil.createDate(95, 2, 4), new Double(0.0)
}), //$NON-NLS-1$
Arrays.asList(new Object[] { new Double(492164.0), new
BigDecimal("390324.0610"), TimestampUtil.createDate(95, 1, 19), new Double(0.0)
}) }; //$NON-NLS-1$
- dataMgr.addData("SELECT g_2.l_orderkey AS c_0, SUM((g_2.l_extendedprice * (1
- g_2.l_discount))) AS c_1, g_1.o_orderdate AS c_2, g_1.o_shippriority AS c_3 FROM
TPCR_Oracle_9i.CUSTOMER AS g_0, TPCR_Oracle_9i.ORDERS AS g_1, TPCR_Oracle_9i.LINEITEM AS
g_2 WHERE (g_0.c_custkey = g_1.o_custkey) AND (g_2.l_orderkey = g_1.o_orderkey) AND
(g_0.c_mktsegment = 'BUILDING') AND (g_1.o_orderdate < {d'1995-03-15'})
AND (g_2.l_shipdate > {ts'1995-03-15 00:00:00.0'}) GROUP BY g_2.l_orderkey,
g_1.o_orderdate, g_1.o_shippriority ORDER BY c_1 DESC NULLS LAST, c_2 NULLS FIRST",
//$NON-NLS-1$
+ dataMgr.addData("SELECT g_2.L_ORDERKEY AS c_0, SUM((g_2.L_EXTENDEDPRICE * (1
- g_2.L_DISCOUNT))) AS c_1, g_1.O_ORDERDATE AS c_2, g_1.O_SHIPPRIORITY AS c_3 FROM
TPCR_Oracle_9i.CUSTOMER AS g_0, TPCR_Oracle_9i.ORDERS AS g_1, TPCR_Oracle_9i.LINEITEM AS
g_2 WHERE (g_0.C_CUSTKEY = g_1.O_CUSTKEY) AND (g_2.L_ORDERKEY = g_1.O_ORDERKEY) AND
(g_0.C_MKTSEGMENT = 'BUILDING') AND (g_1.O_ORDERDATE < {d'1995-03-15'})
AND (g_2.L_SHIPDATE > {ts'1995-03-15 00:00:00.0'}) GROUP BY g_2.L_ORDERKEY,
g_1.O_ORDERDATE, g_1.O_SHIPPRIORITY ORDER BY c_1 DESC NULLS LAST, c_2 NULLS FIRST",
//$NON-NLS-1$
expected);
doProcess(METADATA,
Modified:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-07-09
14:31:47 UTC (rev 4226)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-07-09
18:59:20 UTC (rev 4227)
@@ -295,7 +295,7 @@
Statement s;
try {
s = c.createStatement();
- assertTrue(s.execute("select part_id from parts union all select part_id
from parts"));
+ assertTrue(s.execute("select part_id from parts union all select part_name
from parts"));
ResultSet r = s.getResultSet();
//wake up the other source thread, should put the requestworkitem into the more
work state