teiid SVN: r3178 - in branches/7.4.x: engine/src/main/java/org/teiid/query/optimizer/relational/rules and 8 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-18 00:02:41 -0400 (Wed, 18 May 2011)
New Revision: 3178
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAssignOutputElements.java
branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestParser.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
branches/7.4.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
branches/7.4.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
Log:
TEIID-1587 added access node logic to minimize the final projection
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -341,7 +341,10 @@
}
}
aNode.setCommand(command);
- aNode.setModelName(getRoutingName(node));
+ if (!aNode.isShouldEvaluate()) {
+ aNode.minimizeProject(command);
+ }
+ setRoutingName(aNode, node);
}
break;
@@ -540,7 +543,7 @@
return processNode;
}
- private String getRoutingName(PlanNode node)
+ private void setRoutingName(AccessNode accessNode, PlanNode node)
throws QueryPlannerException, TeiidComponentException {
// Look up connector binding name
@@ -558,7 +561,8 @@
}
}
String cbName = metadata.getFullName(modelID);
- return cbName;
+ accessNode.setModelName(cbName);
+ accessNode.setModelId(modelID);
} catch(QueryMetadataException e) {
throw new QueryPlannerException(e, QueryPlugin.Util.getString("ERR.015.004.0009")); //$NON-NLS-1$
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -63,6 +63,7 @@
import org.teiid.query.optimizer.relational.rules.RuleConstants;
import org.teiid.query.optimizer.relational.rules.RuleMergeCriteria;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
import org.teiid.query.resolver.ProcedureContainerResolver;
@@ -177,11 +178,12 @@
Command subCommand = with.getCommand();
ProcessorPlan procPlan = QueryOptimizer.optimizePlan(subCommand, metadata, idGenerator, capFinder, analysisRecord, context);
subCommand.setProcessorPlan(procPlan);
- QueryCommand withCommand = CriteriaCapabilityValidatorVisitor.getQueryCommand(procPlan);
- if (withCommand != null && supportsWithPushdown) {
- modelID = CriteriaCapabilityValidatorVisitor.validateCommandPushdown(modelID, metadata, capFinder, withCommand);
+ AccessNode aNode = CriteriaCapabilityValidatorVisitor.getAccessNode(procPlan);
+ if (aNode != null && supportsWithPushdown) {
+ modelID = CriteriaCapabilityValidatorVisitor.validateCommandPushdown(modelID, metadata, capFinder, aNode);
}
- if (modelID == null) {
+ QueryCommand withCommand = CriteriaCapabilityValidatorVisitor.getQueryCommand(aNode);
+ if (modelID == null || withCommand == null) {
supportsWithPushdown = false;
} else {
if (pushDownWith == null) {
@@ -226,9 +228,10 @@
RelationalPlan result = planToProcessConverter.convert(plan);
if (withList != null && supportsWithPushdown) {
- QueryCommand queryCommand = CriteriaCapabilityValidatorVisitor.getQueryCommand(result);
- if (queryCommand != null) {
- if (CriteriaCapabilityValidatorVisitor.validateCommandPushdown(modelID, metadata, capFinder, queryCommand) == null) {
+ AccessNode aNode = CriteriaCapabilityValidatorVisitor.getAccessNode(result);
+ if (aNode != null) {
+ QueryCommand queryCommand = CriteriaCapabilityValidatorVisitor.getQueryCommand(aNode);
+ if (queryCommand == null || CriteriaCapabilityValidatorVisitor.validateCommandPushdown(modelID, metadata, capFinder, aNode) == null) {
supportsWithPushdown = false;
} else {
queryCommand.setWith(pushDownWith);
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -23,7 +23,6 @@
package org.teiid.query.optimizer.relational.rules;
import java.util.Arrays;
-import java.util.Collection;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.TeiidComponentException;
@@ -61,8 +60,9 @@
import org.teiid.query.sql.navigator.PostOrderNavigator;
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
@@ -77,7 +77,6 @@
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.EvaluatableVisitor;
import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
-import org.teiid.query.sql.visitor.GroupCollectorVisitor;
/**
@@ -464,17 +463,17 @@
* @return
* @throws TeiidComponentException
*/
- public static Object validateSubqueryPushdown(SubqueryContainer subqueryContainer, Object critNodeModelID,
+ public static Object validateSubqueryPushdown(SubqueryContainer<?> subqueryContainer, Object critNodeModelID,
QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord) throws TeiidComponentException {
ProcessorPlan plan = subqueryContainer.getCommand().getProcessorPlan();
if (plan != null) {
- QueryCommand queryCommand = getQueryCommand(plan);
+ AccessNode aNode = getAccessNode(plan);
- if (queryCommand == null) {
+ if (aNode == null) {
return null;
}
- critNodeModelID = validateCommandPushdown(critNodeModelID, metadata, capFinder, queryCommand);
+ critNodeModelID = validateCommandPushdown(critNodeModelID, metadata, capFinder, aNode);
}
if (critNodeModelID == null) {
return null;
@@ -502,20 +501,13 @@
public static Object validateCommandPushdown(Object critNodeModelID,
QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
- QueryCommand queryCommand) throws TeiidComponentException {
+ AccessNode aNode) throws TeiidComponentException {
// Check that query in access node is for the same model as current node
try {
- Collection<GroupSymbol> subQueryGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(queryCommand, false);
- if(subQueryGroups.size() == 0) {
- // No FROM?
- return null;
- }
- GroupSymbol subQueryGroup = subQueryGroups.iterator().next();
-
- Object modelID = subQueryGroup.getModelMetadataId();
- if (modelID == null) {
- modelID = metadata.getModelID(subQueryGroup.getMetadataID());
- }
+ if (!(aNode.getCommand() instanceof QueryCommand)) {
+ return null;
+ }
+ Object modelID = aNode.getModelId();
if (critNodeModelID == null) {
critNodeModelID = modelID;
} else if(!CapabilitiesUtil.isSameConnector(critNodeModelID, modelID, metadata, capFinder)) {
@@ -527,7 +519,7 @@
return critNodeModelID;
}
- public static QueryCommand getQueryCommand(ProcessorPlan plan) {
+ public static AccessNode getAccessNode(ProcessorPlan plan) {
if(!(plan instanceof RelationalPlan)) {
return null;
}
@@ -545,17 +537,27 @@
accessNode = ln.getChildren()[0];
}
- if (! (accessNode instanceof AccessNode) || accessNode.getChildren()[0] != null) {
+ if (! (accessNode instanceof AccessNode)) {
return null;
}
-
- // Check that command in access node is a query
- Command command = ((AccessNode)accessNode).getCommand();
- if(command == null || !(command instanceof QueryCommand) || ((command instanceof Query) && ((Query)command).getIsXML())) {
+ return (AccessNode)accessNode;
+ }
+
+ public static QueryCommand getQueryCommand(AccessNode aNode) {
+ if (aNode == null) {
+ return null;
+ }
+ Command command = aNode.getCommand();
+ if(!(command instanceof QueryCommand)) {
return null;
}
QueryCommand queryCommand = (QueryCommand)command;
+ if (aNode.getProjection() != null && aNode.getProjection().length > 0) {
+ Query newCommand = (Query)queryCommand.clone();
+ newCommand.getSelect().setSymbols(aNode.getOriginalSelect());
+ return newCommand;
+ }
return queryCommand;
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -45,6 +45,7 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.rewriter.QueryRewriter;
@@ -405,7 +406,8 @@
public static void prepareSubquery(SubqueryContainer container) {
RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan();
- QueryCommand command = CriteriaCapabilityValidatorVisitor.getQueryCommand(subqueryPlan);
+ AccessNode aNode = CriteriaCapabilityValidatorVisitor.getAccessNode(subqueryPlan);
+ QueryCommand command = CriteriaCapabilityValidatorVisitor.getQueryCommand(aNode);
if (command == null) {
return;
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -294,7 +294,7 @@
if (first) {
first = false;
QueryRewriter.makeSelectUnique(allSymbols, false);
- symbols = allSymbols.getSymbols();
+ symbols = allSymbols.getProjectedSymbols();
}
projectPlanNode.setProperty(NodeConstants.Info.PROJECT_COLS, allSymbols.getSymbols());
projectPlanNode.addGroups(view.getGroups());
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -26,6 +26,8 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import org.teiid.api.exception.query.QueryValidatorException;
@@ -43,6 +45,13 @@
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.util.CommandContext;
@@ -63,6 +72,10 @@
private int reserved;
private int schemaSize;
+ private Object[] projection;
+ private List<SelectSymbol> originalSelect;
+ private Object modelId;
+
protected AccessNode() {
super();
}
@@ -93,6 +106,14 @@
public Command getCommand() {
return this.command;
}
+
+ public void setModelId(Object id) {
+ this.modelId = id;
+ }
+
+ public Object getModelId() {
+ return this.modelId;
+ }
public void setModelName(String name) {
this.modelName = name;
@@ -136,7 +157,64 @@
//We hardcode an upper limit on currency because these commands have potentially large in-memory value sets
} while (!processCommandsIndividually() && hasNextCommand() && this.tupleSources.size() < Math.min(MAX_CONCURRENT, this.getContext().getUserRequestSourceConcurrency()));
}
+
+ public boolean isShouldEvaluate() {
+ return shouldEvaluate;
+ }
+ public void minimizeProject(Command atomicCommand) {
+ if (!(atomicCommand instanceof Query)) {
+ return;
+ }
+ Query query = (Query)atomicCommand;
+ Select select = query.getSelect();
+ List<SelectSymbol> symbols = select.getSymbols();
+ if (symbols.size() == 1) {
+ return;
+ }
+ boolean shouldProject = false;
+ LinkedHashMap<Expression, Integer> uniqueSymbols = new LinkedHashMap<Expression, Integer>();
+ projection = new Object[symbols.size()];
+ this.originalSelect = new ArrayList<SelectSymbol>(query.getSelect().getSymbols());
+ int i = 0;
+ int j = 0;
+ for (Iterator<SelectSymbol> iter = symbols.iterator(); iter.hasNext(); ) {
+ SingleElementSymbol ss = (SingleElementSymbol) iter.next();
+ Expression ex = SymbolMap.getExpression(ss);
+ if (ex instanceof Constant) {
+ projection[i] = ex;
+ if (iter.hasNext() || j!=0) {
+ iter.remove();
+ shouldProject = true;
+ } else {
+ projection[i] = j++;
+ }
+ } else {
+ Integer index = uniqueSymbols.get(ex);
+ if (index == null) {
+ uniqueSymbols.put(ex, j);
+ index = j++;
+ } else {
+ iter.remove();
+ shouldProject = true;
+ }
+ projection[i] = index;
+ }
+ i++;
+ }
+ if (!shouldProject) {
+ this.projection = new Object[0];
+ }
+ }
+
+ public List<SelectSymbol> getOriginalSelect() {
+ return originalSelect;
+ }
+
+ public Object[] getProjection() {
+ return projection;
+ }
+
static void rewriteAndEvaluate(Command atomicCommand, Evaluator eval, CommandContext context, QueryMetadataInterface metadata)
throws TeiidProcessingException, TeiidComponentException {
try {
@@ -183,6 +261,17 @@
while ((tuple = tupleSource.nextTuple()) != null) {
returnedRows = true;
+ if (this.projection != null && this.projection.length > 0) {
+ List<Object> newTuple = new ArrayList<Object>(this.projection.length);
+ for (Object object : this.projection) {
+ if (object instanceof Integer) {
+ newTuple.add(tuple.get((Integer)object));
+ } else {
+ newTuple.add(((Constant)object).getValue());
+ }
+ }
+ tuple = newTuple;
+ }
addBatchRow(tuple);
if (isBatchFull()) {
@@ -246,6 +335,10 @@
private void registerRequest(Command atomicCommand)
throws TeiidComponentException, TeiidProcessingException {
+ if (shouldEvaluate) {
+ projection = null;
+ minimizeProject(atomicCommand);
+ }
int limit = -1;
if (getParent() instanceof LimitNode) {
LimitNode parent = (LimitNode)getParent();
@@ -295,8 +388,13 @@
protected void copy(AccessNode source, AccessNode target){
super.copy(source, target);
target.modelName = source.modelName;
+ target.modelId = source.modelId;
target.connectorBindingId = source.connectorBindingId;
target.shouldEvaluate = source.shouldEvaluate;
+ if (!source.shouldEvaluate) {
+ target.projection = source.projection;
+ target.originalSelect = source.originalSelect;
+ }
target.command = source.command;
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -24,17 +24,14 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.symbol.AllInGroupSymbol;
import org.teiid.query.sql.symbol.AllSymbol;
import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.MultipleElementSymbol;
import org.teiid.query.sql.symbol.SelectSymbol;
import org.teiid.query.sql.symbol.SingleElementSymbol;
@@ -48,7 +45,7 @@
public class Select implements LanguageObject {
/** The set of symbols for the data elements to be selected. */
- private List symbols; // List<SelectSymbols>
+ private List<SelectSymbol> symbols;
/** Flag for whether duplicate removal should be performed on the results */
private boolean distinct;
@@ -61,15 +58,15 @@
* Constructs a default instance of this class.
*/
public Select() {
- symbols = new ArrayList();
+ symbols = new ArrayList<SelectSymbol>();
}
/**
* Constructs an instance of this class from an ordered set of symbols.
* @param symbols The ordered list of symbols
*/
- public Select( List symbols ) {
- this.symbols = new ArrayList( symbols );
+ public Select( List<? extends SelectSymbol> symbols ) {
+ this.symbols = new ArrayList<SelectSymbol>( symbols );
}
// =========================================================================
@@ -95,7 +92,7 @@
* Returns an ordered list of the symbols in the select.
* @param Get list of SelectSymbol in SELECT
*/
- public List getSymbols() {
+ public List<SelectSymbol> getSymbols() {
return symbols;
}
@@ -103,8 +100,8 @@
* Sets an ordered list of the symbols in the select.
* @param symbols list of SelectSymbol in SELECT
*/
- public void setSymbols(List symbols) {
- this.symbols = symbols;
+ public void setSymbols(List<? extends SelectSymbol> symbols) {
+ this.symbols = new ArrayList<SelectSymbol>(symbols);
}
/**
@@ -113,7 +110,7 @@
* @return The variable identifier at the index
*/
public SelectSymbol getSymbol( int index ) {
- return (SelectSymbol) symbols.get(index);
+ return symbols.get(index);
}
/**
@@ -130,9 +127,9 @@
* Adds a new collection of symbols to the list of symbols.
* @param symbols Collection of SelectSymbols
*/
- public void addSymbols( Collection symbols) {
+ public void addSymbols( Collection<? extends SelectSymbol> toAdd) {
if(symbols != null) {
- this.symbols.addAll(symbols);
+ this.symbols.addAll(toAdd);
}
}
@@ -152,38 +149,6 @@
return symbols.contains(symbol);
}
- /**
- * Check is the element symbol is being selected by this
- * select clause. This includes checking for select start
- * and select group.star for the group of this element symbol.
- * ElementSymbol is assumed to be fully resolved.
- * @param elementSymbol fully resolved ElementSymbol
- * @return whether this select will select the element symbol
- */
- public boolean isElementBeingSelected(ElementSymbol elementSymbol){
- boolean isBeingSelected = this.containsSymbol(elementSymbol);
- if (!isBeingSelected){
- GroupSymbol g = elementSymbol.getGroupSymbol();
- String groupDotStarName = g.getName() + ".*"; //$NON-NLS-1$
- Iterator i = this.getSymbols().iterator();
- while (i.hasNext()) {
- Object selectSymbol = i.next();
- if (selectSymbol instanceof AllSymbol){
- isBeingSelected = true;
- break;
- } else if (selectSymbol instanceof AllInGroupSymbol){
- AllInGroupSymbol aigSymbol = (AllInGroupSymbol)selectSymbol;
- if (aigSymbol.getName().equalsIgnoreCase(groupDotStarName)){
- isBeingSelected = true;
- break;
- }
- }
- }
- }
- return isBeingSelected;
- }
-
-
/**
* Set whether select is distinct.
* @param isDistinct True if SELECT is distinct
@@ -212,9 +177,7 @@
*/
public List<SingleElementSymbol> getProjectedSymbols() {
ArrayList<SingleElementSymbol> projectedSymbols = new ArrayList<SingleElementSymbol>();
- Iterator iter = symbols.iterator();
- while(iter.hasNext()) {
- SelectSymbol symbol = (SelectSymbol) iter.next();
+ for (SelectSymbol symbol : symbols) {
if(symbol instanceof SingleElementSymbol) {
projectedSymbols.add((SingleElementSymbol)symbol);
} else {
@@ -236,15 +199,7 @@
* @return Deep clone
*/
public Object clone() {
- List thisSymbols = getSymbols();
- List copySymbols = new ArrayList(thisSymbols.size());
- Iterator iter = thisSymbols.iterator();
- while(iter.hasNext()) {
- SelectSymbol ss = (SelectSymbol) iter.next();
- copySymbols.add(ss.clone());
- }
-
- Select copy = new Select(copySymbols);
+ Select copy = new Select(LanguageObject.Util.deepClone(this.symbols, SelectSymbol.class));
copy.setDistinct( isDistinct() );
return copy;
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -408,7 +408,7 @@
String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = null)"; //$NON-NLS-1$
// Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey, null FROM bqt1.smalla"}); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla"}); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -936,16 +936,16 @@
@Test public void testPushCriteriaThroughUnion11() {
helpPlan("select * from vm1.u8 where const = 's3' or e1 is null", example1(), //$NON-NLS-1$
- new String[] { "SELECT 's3', e1 FROM pm1.g3", //$NON-NLS-1$
- "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
- "SELECT 's1', e1 FROM pm1.g1 WHERE e1 IS NULL" } ); //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g3", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g1 WHERE e1 IS NULL" } ); //$NON-NLS-1$
}
@Test public void testPushCriteriaThroughUnion12() {
helpPlan("select * from vm1.u8 where const = 's1' or e1 is null", example1(), //$NON-NLS-1$
- new String[] { "SELECT 's3', e1 FROM pm1.g3 WHERE e1 IS NULL", //$NON-NLS-1$
- "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
- "SELECT 's1', e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g3 WHERE e1 IS NULL", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g1" } ); //$NON-NLS-1$
}
/** defect #4997 */
@@ -1096,8 +1096,8 @@
@Test public void testDefect6425_1() {
helpPlan("select * from vm1.u9", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT e1, e1 FROM pm1.g2" } ); //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
}
@Test public void testDefect6425_2() {
@@ -3507,7 +3507,7 @@
ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
new String[] {
"SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
- "SELECT IntKey, IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
+ "SELECT IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
2, // Access
@@ -3532,7 +3532,7 @@
ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntKey b FROM BQT1.SmallA UNION ALL SELECT IntKey, IntNum FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
new String[] {
"SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
- "SELECT IntKey, IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
+ "SELECT IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
2, // Access
@@ -5411,7 +5411,7 @@
ProcessorPlan plan = helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT g_0.intkey, 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);
@@ -5673,7 +5673,7 @@
helpPlan(sql,
metadata,
null, capFinder,
- new String[] {"SELECT '1', g_0.intkey, '2', 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 );
}
@@ -6020,16 +6020,12 @@
helpTestCase2430and2507(sql, expected);
}
- /*
- * If expressionsymbol comparison would ignore expression names then this should just select a single column,
- * but for now it will select 2.
- */
@Test public void testCase2430E() {
String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
"CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
- String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c1234567890123456789012345678901234567890, CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) " + //$NON-NLS-1$
- "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+ String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c_0 " + //$NON-NLS-1$
+ "FROM bqt1.smalla ORDER BY c_0"; //$NON-NLS-1$
helpTestCase2430and2507(sql, expected);
}
@@ -6037,8 +6033,8 @@
String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
"CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
- String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c1234567890123456789012345678901234567890, CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) " + //$NON-NLS-1$
- "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+ String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c_0 " + //$NON-NLS-1$
+ "FROM bqt1.smalla ORDER BY c_0"; //$NON-NLS-1$
helpTestCase2430and2507(sql, expected);
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -87,7 +87,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x, x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
new String[] {
- "SELECT v_0.c_0, v_0.c_0 FROM (SELECT MAX(g_0.e2) AS c_0 FROM pm1.g1 AS g_0 GROUP BY g_0.e1) AS v_0"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+ "SELECT v_0.c_0 FROM (SELECT MAX(g_0.e2) AS c_0 FROM pm1.g1 AS g_0 GROUP BY g_0.e1) AS v_0"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -68,7 +68,7 @@
String sql = "select * from ( select intkey as cola, null as colb, intnum as colc from bqt1.smalla union all select null, intkey, intnum from bqt2.smalla) as X where X.cola = 1"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {"SELECT intkey, null, intnum FROM bqt1.smalla WHERE intkey = 1"} ); //$NON-NLS-1$
+ new String[] {"SELECT intkey, intnum FROM bqt1.smalla WHERE intkey = 1"} ); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
@@ -107,7 +107,7 @@
String sql = "select smallb.intkey, smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (1 = 2)"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[]{"SELECT null, bqt1.smalla.intkey FROM bqt1.smalla"}, true); //$NON-NLS-1$
+ new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla"}, true); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
@@ -133,7 +133,7 @@
String sql = "select b.intkey, b.x from (select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select intnum as a, null from bqt1.smalla union all select 1 as z, intkey as b from bqt1.smallb) b"; //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT 1, intkey FROM bqt1.smallb", "SELECT IntNum, null FROM bqt1.smalla"}); //$NON-NLS-1$ //$NON-NLS-2$
+ new String[]{"SELECT intkey FROM bqt1.smallb", "SELECT IntNum FROM bqt1.smalla"}); //$NON-NLS-1$ //$NON-NLS-2$
TestOptimizer.checkNodeTypes(plan, new int[] {
2, // Access
0, // DependentAccess
@@ -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, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT 1, 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);
}
@@ -201,12 +201,12 @@
@Test public void testPushCriteriaThroughUnion9() {
TestOptimizer.helpPlan("select * from vm1.u8 where const = 's1'", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT 's1', e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" } ); //$NON-NLS-1$
}
@Test public void testPushCriteriaThroughUnion10() {
TestOptimizer.helpPlan("select * from vm1.u8 where const = 's3'", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT 's3', e1 FROM pm1.g3" } ); //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g3" } ); //$NON-NLS-1$
}
@Test public void testRaiseNullWithOuterJoinAndHaving() {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAssignOutputElements.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAssignOutputElements.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAssignOutputElements.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -22,30 +22,23 @@
package org.teiid.query.optimizer.relational.rules;
-import org.teiid.query.optimizer.relational.plantree.*;
-import org.teiid.query.optimizer.relational.rules.RuleAssignOutputElements;
-import org.teiid.query.sql.lang.SetQuery.Operation;
+import static org.junit.Assert.*;
-import junit.framework.*;
-
+import org.junit.Test;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.SetQuery.Operation;
/**
*/
-public class TestRuleAssignOutputElements extends TestCase {
+public class TestRuleAssignOutputElements {
- /**
- * Constructor for TestRuleAssignOutputElements.
- * @param arg0
- */
- public TestRuleAssignOutputElements(String arg0) {
- super(arg0);
- }
-
public void helpTestIsUnionNoAll(PlanNode node, boolean expected) {
boolean actual = RuleAssignOutputElements.hasDupRemoval(node);
assertEquals("Got incorrect answer finding no all union", expected, actual); //$NON-NLS-1$
}
- public void testFindNoAllUnion1() {
+ @Test public void testFindNoAllUnion1() {
PlanNode projNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
projNode.addLastChild(accessNode);
@@ -53,7 +46,7 @@
helpTestIsUnionNoAll(projNode, false);
}
- public void testFindNoAllUnion2() {
+ @Test public void testFindNoAllUnion2() {
PlanNode unionNode = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
unionNode.setProperty(NodeConstants.Info.SET_OPERATION, Operation.UNION);
unionNode.setProperty(NodeConstants.Info.USE_ALL, Boolean.TRUE);
@@ -70,7 +63,7 @@
helpTestIsUnionNoAll(unionNode, false);
}
- public void testFindNoAllUnion3() {
+ @Test public void testFindNoAllUnion3() {
PlanNode unionNode = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
unionNode.setProperty(NodeConstants.Info.SET_OPERATION, Operation.UNION);
unionNode.setProperty(NodeConstants.Info.USE_ALL, Boolean.FALSE);
@@ -87,7 +80,7 @@
helpTestIsUnionNoAll(unionNode, true);
}
- public void testFindNoAllUnion4() {
+ @Test public void testFindNoAllUnion4() {
PlanNode unionNode1 = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
unionNode1.setProperty(NodeConstants.Info.SET_OPERATION, Operation.UNION);
unionNode1.setProperty(NodeConstants.Info.USE_ALL, Boolean.TRUE);
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -308,7 +308,7 @@
From from = new From(Arrays.asList(predicate));
predicate.getLeftClause().setMakeNotDep(true);
predicate.getRightClause().setMakeDep(true);
- Select select = new Select(Arrays.asList(new Object[] {x, y}));
+ Select select = new Select(Arrays.asList(x, y));
Query query = new Query(select, from, null, null, null, null, null);
TestParser.helpTest("Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)", //$NON-NLS-1$
@@ -996,7 +996,7 @@
option.addDependentGroup("a"); //$NON-NLS-1$
option.addNotDependentGroup("b"); //$NON-NLS-1$
- Select select = new Select(Arrays.asList(new Object[] {x, y}));
+ Select select = new Select(Arrays.asList(x, y));
Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, y);
Query query = new Query(select, from, criteria, null, null, null, option);
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestParser.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/parser/TestParser.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -6436,7 +6436,7 @@
@Test public void testLimit() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
@@ -6446,7 +6446,7 @@
@Test public void testLimitWithOffset() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
@@ -6456,7 +6456,7 @@
@Test public void testLimitWithReferences1() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
@@ -6466,7 +6466,7 @@
@Test public void testLimitWithReferences2() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
@@ -6476,7 +6476,7 @@
@Test public void testLimitWithReferences3() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
@@ -6618,9 +6618,9 @@
String expected = "CREATE PROCEDURE\nBEGIN\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nELSE\nBEGIN\nSELECT 1;\nEND\nEND"; //$NON-NLS-1$
Query query = new Query();
- query.setSelect(new Select(Arrays.asList(new Object[] {new ExpressionSymbol("expr", new Constant(new Integer(1)))}))); //$NON-NLS-1$
+ query.setSelect(new Select(Arrays.asList(new ExpressionSymbol("expr", new Constant(1))))); //$NON-NLS-1$
CommandStatement commandStmt = new CommandStatement(query);
- CompareCriteria criteria = new CompareCriteria(new ElementSymbol("x"), CompareCriteria.GT, new Constant(new Integer(1))); //$NON-NLS-1$
+ CompareCriteria criteria = new CompareCriteria(new ElementSymbol("x"), CompareCriteria.GT, new Constant(1)); //$NON-NLS-1$
Block block = new Block();
block.addStatement(commandStmt);
IfStatement ifStmt = new IfStatement(criteria, block);
@@ -6648,7 +6648,7 @@
Function convert = new Function("convert", new Expression[] {new Constant(null), new Constant("blob")}); //$NON-NLS-1$ //$NON-NLS-2$
Function convert1 = new Function("convert", new Expression[] {new Constant(null), new Constant("clob")}); //$NON-NLS-1$ //$NON-NLS-2$
Function convert2 = new Function("convert", new Expression[] {new Constant(null), new Constant("xml")}); //$NON-NLS-1$ //$NON-NLS-2$
- Select select = new Select(Arrays.asList(new Object[] {new ExpressionSymbol("expr", convert), new ExpressionSymbol("expr1", convert1), new ExpressionSymbol("expr2", convert2)})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Select select = new Select(Arrays.asList(new ExpressionSymbol("expr", convert), new ExpressionSymbol("expr1", convert1), new ExpressionSymbol("expr2", convert2))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Query query = new Query();
query.setSelect(select);
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -7277,7 +7277,10 @@
};
HardcodedDataManager manager = new HardcodedDataManager();
- manager.addData("SELECT 'a', pm1.g1.e1 FROM pm1.g1", expected); //$NON-NLS-1$
+ manager.addData("SELECT pm1.g1.e1 FROM pm1.g1", new List[] {
+ Arrays.asList("b"), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList("c") //$NON-NLS-1$ //$NON-NLS-2$
+ }); //$NON-NLS-1$
processPreparedStatement("select ?, e1 from pm1.g1", expected, manager, capFinder,
metadata, Arrays.asList("a"));
@@ -7648,5 +7651,30 @@
helpProcess(plan, dataManager, expected);
}
+
+ @Test public void testDupSelect() throws Exception {
+ String sql = "select e1, e1 from pm1.g1";
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT g_0.e1 FROM pm1.g1 AS g_0", new List[] {Arrays.asList(1)});
+
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ helpProcess(plan, dataManager, new List[] {Arrays.asList(1, 1)});
+ }
+
+ @Test public void testDupSelect1() throws Exception {
+ String sql = "select 1, 2 from pm1.g1";
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT 2 FROM pm1.g1 AS g_0", new List[] {Arrays.asList(2)});
+
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ helpProcess(plan, dataManager, new List[] {Arrays.asList(1, 2)});
+ }
+
private static final boolean DEBUG = false;
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -69,7 +69,7 @@
@Test public void testIntersectExcept() {
String sql = "select e1, e2 from pm1.g2 except select e1, 1 from pm1.g2 intersect select 'a', e2 from pm1.g2"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1, 1 FROM pm1.g2 AS g_0", "SELECT g_0.e1, g_0.e2 FROM pm1.g2 AS g_0", "SELECT 'a', g_0.e2 FROM pm1.g2 AS g_0"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1 FROM pm1.g2 AS g_0", "SELECT g_0.e1, g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g2 AS g_0"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
List<?>[] expected = new List[] {
Arrays.asList(new Object[] {null, 1}),
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -69,5 +69,20 @@
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
}
+
+ @Test public void testWithPushdownWithConstants() throws TeiidException {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.COMMON_TABLE_EXPRESSIONS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "with a (x, y) as (select 1, 2 from pm1.g1) SELECT a.x from a, a z"; //$NON-NLS-1$
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y) AS (SELECT 1, 2 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+ }
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -1851,7 +1851,7 @@
public void testLimit() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
@@ -1861,7 +1861,7 @@
public void testLimitWithOffset() {
Query query = new Query();
- Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
+ Select select = new Select(Arrays.asList(new AllSymbol()));
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
query.setSelect(select);
query.setFrom(from);
Modified: branches/7.4.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
===================================================================
--- branches/7.4.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2011-05-17 15:00:54 UTC (rev 3177)
+++ branches/7.4.x/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2011-05-18 04:02:41 UTC (rev 3178)
@@ -74,18 +74,14 @@
Timestamp ts = new Timestamp(-2106305630000l);
ts.setNanos(3000000);
- dataMgr.addData("SELECT g_0.\"timestamp\", g_0.\"double\", g_0.\"float\", convert(g_0.\"double\", biginteger), convert(g_0.\"double\", biginteger), convert(g_0.\"date\", timestamp), convert(g_0.\"double\", biginteger), convert(g_0.\"date\", timestamp), '1' FROM sample.RUNTIMEVALUE AS g_0", //$NON-NLS-1$
+ dataMgr.addData("SELECT g_0.\"timestamp\", g_0.\"double\", g_0.\"float\", convert(g_0.\"double\", biginteger), convert(g_0.\"date\", timestamp) FROM sample.RUNTIMEVALUE AS g_0", //$NON-NLS-1$
new List[] { Arrays.asList(new Object[] {
ts,
new Double(Double.NEGATIVE_INFINITY),
new Float(Float.POSITIVE_INFINITY),
new BigInteger("100"), //$NON-NLS-1$
- new BigInteger("100"), //$NON-NLS-1$
ts,
- new BigInteger("100"), //$NON-NLS-1$
- ts,
- "1" //$NON-NLS-1$
})});