Author: shawkins
Date: 2012-05-15 22:06:17 -0400 (Tue, 15 May 2012)
New Revision: 4108
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
Log:
TEIID-2040 fix for sort init error
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2012-05-16
02:06:06 UTC (rev 4107)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2012-05-16
02:06:17 UTC (rev 4108)
@@ -200,11 +200,10 @@
return this.executionFactory;
}
- public void setExecutionFactory(ExecutionFactory<Object, Object> ef) {
- this.executionFactory = ef;
+ public void setExecutionFactory(ExecutionFactory<?, ?> ef) {
+ this.executionFactory = (ExecutionFactory<Object, Object>) ef;
}
-
/**
* Get the ConnectionFactory object required by this manager
* @return
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2012-05-16
02:06:06 UTC (rev 4107)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2012-05-16
02:06:17 UTC (rev 4108)
@@ -393,11 +393,13 @@
if (hints.hasRelationalProc) {
rules.push(RuleConstants.PLAN_PROCEDURES);
}
+ if (hints.hasJoin) {
+ rules.push(RuleConstants.CHOOSE_DEPENDENT);
+ }
if(hints.hasAggregates) {
rules.push(new RulePushAggregates(idGenerator));
}
if(hints.hasJoin) {
- rules.push(RuleConstants.CHOOSE_DEPENDENT);
rules.push(RuleConstants.CHOOSE_JOIN_STRATEGY);
rules.push(RuleConstants.RAISE_ACCESS);
//after planning the joins, let the criteria be pushed back into place
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2012-05-16
02:06:06 UTC (rev 4107)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2012-05-16
02:06:17 UTC (rev 4108)
@@ -1298,7 +1298,8 @@
depExpressions.add(dsc.getExpression());
continue;
}
- if (sourceNode.getType() == NodeConstants.Types.SOURCE) {
+ switch (sourceNode.getType()) {
+ case NodeConstants.Types.SOURCE: {
PlanNode child = sourceNode.getFirstChild();
child = FrameUtil.findOriginatingNode(child, child.getGroups());
if (child != null && child.getType() == NodeConstants.Types.SET_OP) {
@@ -1320,7 +1321,16 @@
NodeEditor.removeChildNode(planNode.getParent(), planNode);
}
rpsc.getCreatedNodes().clear();
- }
+ break;
+ }
+ case NodeConstants.Types.GROUP: {
+ if (rpsc.pushAcrossGroupBy(sourceNode, critNode, metadata, false)) {
+ critNodes.add(critNode);
+ initialTargets.add(sourceNode.getFirstChild());
+ }
+ break;
+ }
+ }
//the source must be a null or project node, which we don't care about
}
return targets;
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java 2012-05-16
02:06:06 UTC (rev 4107)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java 2012-05-16
02:06:17 UTC (rev 4108)
@@ -136,13 +136,7 @@
}
case NodeConstants.Types.GROUP:
{
- if (!critNode.hasBooleanProperty(NodeConstants.Info.IS_HAVING)) {
- SymbolMap symbolMap = (SymbolMap)
sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
- FrameUtil.convertNode(critNode, null, null, symbolMap.asMap(),
metadata, true);
- NodeEditor.removeChildNode(critNode.getParent(), critNode);
- sourceNode.getFirstChild().addAsParent(critNode);
- moved = true;
- }
+ moved = pushAcrossGroupBy(sourceNode, critNode, metadata, true);
}
}
@@ -157,6 +151,29 @@
return plan;
}
+ boolean pushAcrossGroupBy(PlanNode sourceNode,
+ PlanNode critNode, QueryMetadataInterface metadata, boolean inPlan)
+ throws QueryPlannerException {
+ boolean moved = false;
+ if (!critNode.hasBooleanProperty(NodeConstants.Info.IS_HAVING)) {
+ SymbolMap symbolMap = (SymbolMap)
sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
+ FrameUtil.convertNode(critNode, null, null, symbolMap.asMap(), metadata, true);
+ if (inPlan) {
+ NodeEditor.removeChildNode(critNode.getParent(), critNode);
+ sourceNode.getFirstChild().addAsParent(critNode);
+ }
+ moved = true;
+ if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
+ PlanNode accessNode = NodeEditor.findParent(critNode, NodeConstants.Types.ACCESS);
+ if (accessNode != null) {
+ markDependent(critNode, accessNode);
+ moved = false; //terminal position
+ }
+ }
+ }
+ return moved;
+ }
+
private PlanNode findOriginatingNode(QueryMetadataInterface metadata,
CapabilitiesFinder capFinder, PlanNode critNode, AnalysisRecord record)
throws TeiidComponentException, QueryMetadataException {
@@ -302,7 +319,8 @@
currentNode = path.pop();
// Look for situations where we don't allow SELECT to be pushed
- if(currentNode.getType() == NodeConstants.Types.ACCESS) {
+ switch (currentNode.getType()) {
+ case NodeConstants.Types.ACCESS:
try {
if (!RuleRaiseAccess.canRaiseOverSelect(currentNode, metadata,
capFinder, critNode, null)) {
return currentNode;
@@ -311,7 +329,8 @@
satisfyAccessPatterns(critNode, currentNode);
}
- if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET))
{
+ if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)
+ && NodeEditor.findNodePreOrder(currentNode.getFirstChild(),
NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE) == null) {
//once a dependent crit node is pushed, don't bother pushing
it further into the command
//dependent access node will use this as an assumption for where
dependent sets can appear in the command
critNode.setProperty(NodeConstants.Info.IS_PUSHED,
Boolean.TRUE);
@@ -321,7 +340,8 @@
} catch(QueryMetadataException e) {
throw new QueryPlannerException(QueryPlugin.Event.TEIID30267, e,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30267, currentNode.getGroups()));
}
- } else if(currentNode.getType() == NodeConstants.Types.JOIN) {
+ break;
+ case NodeConstants.Types.JOIN:
//pushing below a join is not necessary under an access node
if (this.createdNodes == null && NodeEditor.findParent(currentNode,
NodeConstants.Types.ACCESS) != null) {
return currentNode;
@@ -343,14 +363,25 @@
}
satisfyAccessPatterns(critNode, currentNode);
- } else if (FrameUtil.isOrderedOrStrictLimit(currentNode)) {
- return currentNode;
- }
+ break;
+ default:
+ if (FrameUtil.isOrderedOrStrictLimit(currentNode)) {
+ return currentNode;
+ }
+ }
}
-
return sourceNode;
}
+ private void markDependent(PlanNode critNode, PlanNode accessNode) {
+ //once a dependent crit node is pushed, don't bother pushing it further into the
command
+ //dependent access node will use this as an assumption for where dependent sets can
appear in the command
+ critNode.setProperty(NodeConstants.Info.IS_PUSHED, Boolean.TRUE);
+ if (createdNodes == null) {
+ accessNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
+ }
+ }
+
boolean pushAcrossFrame(PlanNode sourceNode, PlanNode critNode, QueryMetadataInterface
metadata)
throws QueryPlannerException {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2012-05-16
02:06:06 UTC (rev 4107)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2012-05-16
02:06:17 UTC (rev 4108)
@@ -636,8 +636,8 @@
ProcessorPlan plan = TestProcessor.helpGetPlan(command, metadata, finder,
context);
TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
+ 1, // Access
+ 1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
@@ -652,7 +652,7 @@
0 // UnionAll
});
- TestOptimizer.checkDependentJoinCount(plan, 0);
+ TestOptimizer.checkDependentJoinCount(plan, 1);
// Run query
TestProcessor.helpProcess(plan, context, dataManager, expected);
}