teiid SVN: r4107 - in branches/7.7.x/engine/src: main/java/org/teiid/query/optimizer/relational and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-15 22:06:06 -0400 (Tue, 15 May 2012)
New Revision: 4107
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
Log:
TEIID-2040 fix for sort init error
Modified: branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2012-05-15 23:34:40 UTC (rev 4106)
+++ branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java 2012-05-16 02:06:06 UTC (rev 4107)
@@ -264,11 +264,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: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2012-05-15 23:34:40 UTC (rev 4106)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2012-05-16 02:06:06 UTC (rev 4107)
@@ -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: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2012-05-15 23:34:40 UTC (rev 4106)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2012-05-16 02:06:06 UTC (rev 4107)
@@ -25,17 +25,7 @@
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.Map.Entry;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -55,19 +45,7 @@
import org.teiid.query.optimizer.relational.plantree.PlanNode;
import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
import org.teiid.query.resolver.util.ResolverUtil;
-import org.teiid.query.sql.lang.AbstractSetCriteria;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.DependentSetCriteria;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
-import org.teiid.query.sql.lang.PredicateCriteria;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.lang.SetQuery;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -1321,7 +1299,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) {
@@ -1343,7 +1322,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: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java 2012-05-15 23:34:40 UTC (rev 4106)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java 2012-05-16 02:06:06 UTC (rev 4107)
@@ -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,17 +329,16 @@
satisfyAccessPatterns(critNode, currentNode);
}
- if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
- //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);
- currentNode.setProperty(NodeConstants.Info.IS_DEPENDENT_SET, Boolean.TRUE);
+ if (critNode.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)
+ && NodeEditor.findNodePreOrder(currentNode.getFirstChild(), NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE) == null) {
+ markDependent(critNode, currentNode);
return currentNode.getFirstChild();
}
} catch(QueryMetadataException e) {
throw new QueryPlannerException(e, QueryPlugin.Util.getString("ERR.015.004.0020", currentNode.getGroups())); //$NON-NLS-1$
}
- } 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 +360,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: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2012-05-15 23:34:40 UTC (rev 4106)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2012-05-16 02:06:06 UTC (rev 4107)
@@ -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);
}
12 years, 8 months
teiid SVN: r4106 - in trunk: jboss-integration/src/main/java/org/teiid/jboss and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-05-15 19:34:40 -0400 (Tue, 15 May 2012)
New Revision: 4106
Modified:
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
Log:
TEIID-2047: fixing the Schema merge to be correct
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-05-15 21:26:51 UTC (rev 4105)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-05-15 23:34:40 UTC (rev 4106)
@@ -174,7 +174,7 @@
if (obj.getUpdateInfo() != null && obj.getUpdateInfo().isInherentInsert()) {
try {
if (obj.getUpdateInfo().findInsertUpdateMapping(obj, false) == null) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.nonUpdatable", obj.getVariables()), obj); //$NON-NLS-1$
+ handleValidationError(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30376, obj.getVariables()), obj);
}
} catch (QueryValidatorException e) {
handleValidationError(e.getMessage(), obj);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-05-15 21:26:51 UTC (rev 4105)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-05-15 23:34:40 UTC (rev 4106)
@@ -315,6 +315,8 @@
// designer based models define data types based on their built in data types, which are system vdb data types
Map<String, Datatype> datatypes = indexStore?getVDBRepository().getSystemStore().getDatatypes():getVDBRepository().getBuiltinDatatypes();
factory = new MetadataFactory(vdb.getName(), vdb.getVersion(), model.getName(), datatypes, model.getProperties(), model.getSchemaText());
+ factory.setPhysical(model.isSource());
+ factory.setVisible(model.isVisible());
ExecutionFactory ef = null;
Object cf = null;
12 years, 8 months
teiid SVN: r4104 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-15 17:26:51 -0400 (Tue, 15 May 2012)
New Revision: 4104
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
Log:
TEIID-2045 fix for insert with query expression
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2012-05-15 21:19:01 UTC (rev 4103)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2012-05-15 21:26:51 UTC (rev 4104)
@@ -22,16 +22,7 @@
package org.teiid.query.optimizer.relational.rules;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
@@ -514,7 +505,7 @@
if(sourceNode.getType() != NodeConstants.Types.SOURCE) {
sourceNode = sourceNode.getFirstChild();
}
- if(sourceNode != null && sourceNode.getType() == NodeConstants.Types.SOURCE) {
+ if(sourceNode != null && sourceNode.getType() == NodeConstants.Types.SOURCE && sourceNode.getChildCount() == 0) {
Command command = (Command) sourceNode.getProperty(NodeConstants.Info.VIRTUAL_COMMAND);
if(! (command instanceof QueryCommand)) {
return command;
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-05-15 21:19:01 UTC (rev 4103)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-05-15 21:26:51 UTC (rev 4104)
@@ -100,7 +100,11 @@
addDistinct(metadata, capFinder, accessNode, queryCommand);
command = queryCommand;
if (intoGroup != null) {
- Insert insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
+ Insert insertCommand = (Insert)commandRoot.getParent().getProperty(NodeConstants.Info.VIRTUAL_COMMAND);
+ if (insertCommand == null) {
+ //TODO: this is probably no longer needed as we rewrite select into
+ insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
+ }
insertCommand.setQueryExpression(queryCommand);
command = insertCommand;
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java 2012-05-15 21:19:01 UTC (rev 4103)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java 2012-05-15 21:26:51 UTC (rev 4104)
@@ -15,6 +15,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
@@ -367,7 +368,7 @@
// if not doBulkInsert and is doBatching,
// check the command hist to ensure it contains the expected commands
if ( !doBulkInsert && doBatching ) {
- BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(2);
+ BatchedUpdateCommand bu = (BatchedUpdateCommand)dataManager.getCommandHistory().get(2);
assertEquals(2, bu.getUpdateCommands().size());
assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
@@ -390,5 +391,41 @@
// Run query
helpProcess(plan, dataManager, expected);
}
+
+ @Test public void testInsertQueryExpression() throws Exception {
+ String sql = "insert into pm1.g1 select * from pm1.g2"; //$NON-NLS-1$
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, true);
+ DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps);
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
+ List<?>[] expected = new List<?>[] {Arrays.asList(1)};
+ dataManager.addData("INSERT INTO g1 (e1, e2, e3, e4) SELECT g2.e1, g2.e2, g2.e3, g2.e4 FROM g2", expected);
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testInsertQueryExpression1() throws Exception {
+ String sql = "insert into pm1.g1 (e1) select e1 from pm1.g2"; //$NON-NLS-1$
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, true);
+ DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps);
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+
+ Command command = helpParse(sql);
+
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
+ List<?>[] expected = new List<?>[] {Arrays.asList(1)};
+ dataManager.addData("INSERT INTO g1 (e1) SELECT g2.e1 FROM g2", expected);
+ helpProcess(plan, dataManager, expected);
+ }
+
}
12 years, 8 months
teiid SVN: r4105 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-15 17:26:51 -0400 (Tue, 15 May 2012)
New Revision: 4105
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
Log:
TEIID-2045 fix for insert with query expression
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2012-05-15 21:26:51 UTC (rev 4104)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2012-05-15 21:26:51 UTC (rev 4105)
@@ -504,7 +504,7 @@
if(sourceNode.getType() != NodeConstants.Types.SOURCE) {
sourceNode = sourceNode.getFirstChild();
}
- if(sourceNode != null && sourceNode.getType() == NodeConstants.Types.SOURCE) {
+ if(sourceNode != null && sourceNode.getType() == NodeConstants.Types.SOURCE && sourceNode.getChildCount() == 0) {
Command command = (Command) sourceNode.getProperty(NodeConstants.Info.VIRTUAL_COMMAND);
if(! (command instanceof QueryCommand)) {
return command;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-05-15 21:26:51 UTC (rev 4104)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-05-15 21:26:51 UTC (rev 4105)
@@ -100,7 +100,11 @@
addDistinct(metadata, capFinder, accessNode, queryCommand);
command = queryCommand;
if (intoGroup != null) {
- Insert insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
+ Insert insertCommand = (Insert)commandRoot.getParent().getProperty(NodeConstants.Info.VIRTUAL_COMMAND);
+ if (insertCommand == null) {
+ //TODO: this is probably no longer needed as we rewrite select into
+ insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
+ }
insertCommand.setQueryExpression(queryCommand);
command = insertCommand;
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java 2012-05-15 21:26:51 UTC (rev 4104)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java 2012-05-15 21:26:51 UTC (rev 4105)
@@ -15,6 +15,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
@@ -369,7 +370,7 @@
// if not doBulkInsert and is doBatching,
// check the command hist to ensure it contains the expected commands
if ( !doBulkInsert && doBatching ) {
- BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(2);
+ BatchedUpdateCommand bu = (BatchedUpdateCommand)dataManager.getCommandHistory().get(2);
assertEquals(2, bu.getUpdateCommands().size());
assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
@@ -392,5 +393,41 @@
// Run query
helpProcess(plan, dataManager, expected);
}
+
+ @Test public void testInsertQueryExpression() throws Exception {
+ String sql = "insert into pm1.g1 select * from pm1.g2"; //$NON-NLS-1$
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, true);
+ DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps);
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
+ List<?>[] expected = new List<?>[] {Arrays.asList(1)};
+ dataManager.addData("INSERT INTO g1 (e1, e2, e3, e4) SELECT g2.e1, g2.e2, g2.e3, g2.e4 FROM g2", expected);
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testInsertQueryExpression1() throws Exception {
+ String sql = "insert into pm1.g1 (e1) select e1 from pm1.g2"; //$NON-NLS-1$
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.INSERT_WITH_QUERYEXPRESSION, true);
+ DefaultCapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps);
+
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+
+ Command command = helpParse(sql);
+
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
+ List<?>[] expected = new List<?>[] {Arrays.asList(1)};
+ dataManager.addData("INSERT INTO g1 (e1) SELECT g2.e1 FROM g2", expected);
+ helpProcess(plan, dataManager, expected);
+ }
+
}
12 years, 8 months
teiid SVN: r4103 - trunk/admin/src/main/java/org/teiid/adminapi/impl.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-05-15 17:19:01 -0400 (Tue, 15 May 2012)
New Revision: 4103
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
Log:
TEIID-2046: StaxSource is not supported by the apache.xerces library which is used by AS7 runtime.
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2012-05-15 18:48:10 UTC (rev 4102)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2012-05-15 21:19:01 UTC (rev 4103)
@@ -24,20 +24,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
import javax.xml.XMLConstants;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.stax.StAXSource;
+import javax.xml.stream.*;
+import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
@@ -83,15 +74,12 @@
return null;
}
- public static void validate(InputStream content) throws SAXException,
- IOException, XMLStreamException {
+ public static void validate(InputStream content) throws SAXException, IOException {
try {
- XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
- XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
Validator v = schema.newValidator();
- v.validate(new StAXSource(reader));
+ v.validate(new StreamSource(content));
} finally {
content.close();
}
12 years, 8 months
teiid SVN: r4102 - in branches/7.7.x: connectors/translator-object and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-15 14:48:10 -0400 (Tue, 15 May 2012)
New Revision: 4102
Modified:
branches/7.7.x/connectors/connector-infinispan/
branches/7.7.x/connectors/translator-object/
branches/7.7.x/documentation/javadocs/
Log:
updating ignores
Property changes on: branches/7.7.x/connectors/connector-infinispan
___________________________________________________________________
Added: svn:ignore
+ target
Property changes on: branches/7.7.x/connectors/translator-object
___________________________________________________________________
Added: svn:ignore
+ bin
target
.project
Property changes on: branches/7.7.x/documentation/javadocs
___________________________________________________________________
Added: svn:ignore
+ bin
.project
12 years, 8 months
teiid SVN: r4101 - in branches/7.7.x: engine/src/main/java/org/teiid/dqp/internal/process and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-14 00:47:44 -0400 (Mon, 14 May 2012)
New Revision: 4101
Modified:
branches/7.7.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/7.7.x/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
Log:
TEIID-2042 limiting debug plan size
Modified: branches/7.7.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/7.7.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-05-14 04:47:40 UTC (rev 4100)
+++ branches/7.7.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-05-14 04:47:44 UTC (rev 4101)
@@ -487,11 +487,17 @@
if (show.equalsIgnoreCase("PLAN")) { //$NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
PlanNode plan = driverConnection.getCurrentPlanDescription();
- if (plan != null) {
+ String connDebugLog = driverConnection.getDebugLog();
+ if (plan != null || connDebugLog != null) {
ArrayList<Object> row = new ArrayList<Object>(3);
- row.add(DataTypeTransformer.getClob(plan.toString()));
- row.add(new SQLXMLImpl(plan.toXml()));
- row.add(DataTypeTransformer.getClob(driverConnection.getDebugLog()));
+ if (plan != null) {
+ row.add(DataTypeTransformer.getClob(plan.toString()));
+ row.add(new SQLXMLImpl(plan.toXml()));
+ } else {
+ row.add(null);
+ row.add(null);
+ }
+ row.add(DataTypeTransformer.getClob(connDebugLog));
records.add(row);
}
createResultSet(records, new String[] {"PLAN_TEXT", "PLAN_XML", "DEBUG_LOG"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Modified: branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-05-14 04:47:40 UTC (rev 4100)
+++ branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-05-14 04:47:44 UTC (rev 4101)
@@ -516,7 +516,11 @@
}
}
}
- request.processRequest();
+ try {
+ request.processRequest();
+ } finally {
+ analysisRecord = request.analysisRecord;
+ }
originalCommand = request.userCommand;
if (cachable && (requestMsg.useResultSetCache() || originalCommand.getCacheHint() != null) && rsCache != null && originalCommand.areResultsCachable()) {
this.cid = cacheId;
@@ -566,7 +570,6 @@
//This is just a dummy result it will get replaced by collector source
resultsBuffer = this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(), this.request.context.getConnectionID(), TupleSourceType.FINAL);
}
- analysisRecord = request.analysisRecord;
transactionContext = request.transactionContext;
if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
this.transactionState = TransactionState.ACTIVE;
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2012-05-14 04:47:40 UTC (rev 4100)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2012-05-14 04:47:44 UTC (rev 4101)
@@ -33,6 +33,7 @@
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.PlanNode;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -54,7 +55,9 @@
*/
public class AnalysisRecord {
- // Common
+ private static final int MAX_PLAN_LENGTH = PropertiesUtils.getIntProperty(System.getProperties(), "org.teiid.maxPlanLength", 1<<25); //$NON-NLS-1$
+
+ // Common
public static final String PROP_OUTPUT_COLS = "Output Columns"; //$NON-NLS-1$
// Relational
@@ -178,6 +181,9 @@
* @param debugLine Text to add to debug writer
*/
public void println(String debugLine) {
+ if (this.stringWriter.getBuffer().length() > MAX_PLAN_LENGTH) {
+ this.stringWriter.getBuffer().delete(0, this.stringWriter.getBuffer().length() - (MAX_PLAN_LENGTH*3/4));
+ }
this.debugWriter.println(debugLine);
}
12 years, 8 months
teiid SVN: r4100 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-14 00:47:40 -0400 (Mon, 14 May 2012)
New Revision: 4100
Modified:
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
Log:
TEIID-2042 limiting debug plan size
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-05-14 03:46:04 UTC (rev 4099)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-05-14 04:47:40 UTC (rev 4100)
@@ -554,11 +554,17 @@
if (show.equalsIgnoreCase("PLAN")) { //$NON-NLS-1$
List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
PlanNode plan = driverConnection.getCurrentPlanDescription();
- if (plan != null) {
+ String connDebugLog = driverConnection.getDebugLog();
+ if (plan != null || connDebugLog != null) {
ArrayList<Object> row = new ArrayList<Object>(3);
- row.add(DataTypeTransformer.getClob(plan.toString()));
- row.add(new SQLXMLImpl(plan.toXml()));
- row.add(DataTypeTransformer.getClob(driverConnection.getDebugLog()));
+ if (plan != null) {
+ row.add(DataTypeTransformer.getClob(plan.toString()));
+ row.add(new SQLXMLImpl(plan.toXml()));
+ } else {
+ row.add(null);
+ row.add(null);
+ }
+ row.add(DataTypeTransformer.getClob(connDebugLog));
records.add(row);
}
createResultSet(records, new String[] {"PLAN_TEXT", "PLAN_XML", "DEBUG_LOG"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
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-05-14 03:46:04 UTC (rev 4099)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-05-14 04:47:40 UTC (rev 4100)
@@ -531,7 +531,11 @@
}
}
}
- request.processRequest();
+ try {
+ request.processRequest();
+ } finally {
+ analysisRecord = request.analysisRecord;
+ }
originalCommand = request.userCommand;
if (cachable && (requestMsg.useResultSetCache() || originalCommand.getCacheHint() != null) && rsCache != null && originalCommand.areResultsCachable()) {
this.cid = cacheId;
@@ -581,7 +585,6 @@
//This is just a dummy result it will get replaced by collector source
resultsBuffer = this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(), this.request.context.getConnectionId(), TupleSourceType.FINAL);
}
- analysisRecord = request.analysisRecord;
transactionContext = request.transactionContext;
if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
if (this.requestMsg.getRequestOptions().isContinuous()) {
Modified: trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2012-05-14 03:46:04 UTC (rev 4099)
+++ trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2012-05-14 04:47:40 UTC (rev 4100)
@@ -33,6 +33,7 @@
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.PlanNode;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -55,7 +56,9 @@
*/
public class AnalysisRecord {
- // Common
+ private static final int MAX_PLAN_LENGTH = PropertiesUtils.getIntProperty(System.getProperties(), "org.teiid.maxPlanLength", 1<<25); //$NON-NLS-1$
+
+ // Common
public static final String PROP_OUTPUT_COLS = "Output Columns"; //$NON-NLS-1$
// Relational
@@ -179,6 +182,9 @@
* @param debugLine Text to add to debug writer
*/
public void println(String debugLine) {
+ if (this.stringWriter.getBuffer().length() > MAX_PLAN_LENGTH) {
+ this.stringWriter.getBuffer().delete(0, this.stringWriter.getBuffer().length() - (MAX_PLAN_LENGTH*3/4));
+ }
this.debugWriter.println(debugLine);
}
12 years, 8 months
teiid SVN: r4099 - in trunk/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-13 23:46:04 -0400 (Sun, 13 May 2012)
New Revision: 4099
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
Log:
TEIID-2041 correctly adding ruleraisenull
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java 2012-05-14 03:45:48 UTC (rev 4098)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java 2012-05-14 03:46:04 UTC (rev 4099)
@@ -72,7 +72,7 @@
pushRaiseNull |= clean(node);
}
if (plan.getType() == NodeConstants.Types.SELECT) {
- pushRaiseNull = cleanCriteria(plan);
+ pushRaiseNull |= cleanCriteria(plan);
}
return pushRaiseNull;
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2012-05-14 03:45:48 UTC (rev 4098)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2012-05-14 03:46:04 UTC (rev 4099)
@@ -339,6 +339,12 @@
TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
}
+ @Test public void testCleanCriteria() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * from (Select 'x' as c from pm1.g1, pm2.g1 where pm1.g1.e1 = 'a') y where c = 'y'", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { });
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
@Test public void testRaiseNullWithUnionNotAll() {
String sql = "select intkey from bqt2.smalla union select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
12 years, 8 months
teiid SVN: r4098 - in branches/7.7.x/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-05-13 23:45:48 -0400 (Sun, 13 May 2012)
New Revision: 4098
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
Log:
TEIID-2041 correctly adding ruleraisenull
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java 2012-05-10 19:03:30 UTC (rev 4097)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java 2012-05-14 03:45:48 UTC (rev 4098)
@@ -71,7 +71,7 @@
pushRaiseNull |= clean(node);
}
if (plan.getType() == NodeConstants.Types.SELECT) {
- pushRaiseNull = cleanCriteria(plan);
+ pushRaiseNull |= cleanCriteria(plan);
}
return pushRaiseNull;
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2012-05-10 19:03:30 UTC (rev 4097)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2012-05-14 03:45:48 UTC (rev 4098)
@@ -339,6 +339,12 @@
TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
}
+ @Test public void testCleanCriteria() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * from (Select 'x' as c from pm1.g1, pm2.g1 where pm1.g1.e1 = 'a') y where c = 'y'", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { });
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
@Test public void testRaiseNullWithUnionNotAll() {
String sql = "select intkey from bqt2.smalla union select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
12 years, 8 months