Author: shawkins
Date: 2009-12-11 18:05:15 -0500 (Fri, 11 Dec 2009)
New Revision: 1656
Added:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
Log:
TEIID-900 changing to more uniformly propagate the no cache hint and to make the table
specific no cache apply only to one level
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -445,7 +445,7 @@
if(command instanceof Insert){
Insert insert = (Insert)command;
if (insert.getQueryExpression() != null) {
- PlanNode plan = createQueryPlan(insert.getQueryExpression());
+ PlanNode plan = generatePlan(insert.getQueryExpression());
attachLast(sourceNode, plan);
mergeTempMetadata(insert.getQueryExpression(), insert);
projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
@@ -694,16 +694,14 @@
MetaMatrixComponentException, QueryResolverException,
QueryValidatorException, QueryMetadataException {
if (nestedCommand instanceof QueryCommand) {
+ //remove unnecessary order by
QueryCommand queryCommand = (QueryCommand)nestedCommand;
if (queryCommand.getLimit() == null) {
queryCommand.setOrderBy(null);
}
}
node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
- // Create symbol map from virtual group to child plan
- List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
- node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group,
projectCols));
-
+
if (merge && nestedCommand instanceof Query &&
QueryResolver.isXMLQuery((Query)nestedCommand, metadata)) {
merge = false;
}
@@ -712,6 +710,8 @@
mergeTempMetadata(nestedCommand, parentCommand);
PlanNode childRoot = generatePlan(nestedCommand);
node.addFirstChild(childRoot);
+ List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
+ node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group,
projectCols, metadata));
} else {
QueryMetadataInterface actualMetadata = metadata;
if (actualMetadata instanceof TempMetadataAdapter) {
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -208,7 +208,20 @@
//update the parent plan with the staged aggregates and the new projected symbols
List<SingleElementSymbol> projectedViewSymbols =
(List<SingleElementSymbol>)NodeEditor.findNodePreOrder(child,
NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- SymbolMap newParentMap = SymbolMap.createSymbolMap(child.getGroups().iterator().next(),
projectedViewSymbols);
+ List<ElementSymbol> updatedVirturalElement = new
ArrayList<ElementSymbol>(virtualElements);
+
+ //hack to introduce aggregate symbols to the parent view TODO: this should change the
metadata properly.
+ GroupSymbol virtualGroup = child.getGroups().iterator().next();
+ for (int i = updatedVirturalElement.size(); i < projectedViewSymbols.size(); i++) {
+ SingleElementSymbol symbol = projectedViewSymbols.get(i);
+ String name = symbol.getShortName();
+ String virtualElementName = virtualGroup.getCanonicalName() +
ElementSymbol.SEPARATOR + name;
+ ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
+ virtualElement.setGroupSymbol(virtualGroup);
+ virtualElement.setType(symbol.getType());
+ updatedVirturalElement.add(virtualElement);
+ }
+ SymbolMap newParentMap = SymbolMap.createSymbolMap(updatedVirturalElement,
projectedViewSymbols);
child.setProperty(NodeConstants.Info.SYMBOL_MAP, newParentMap);
Map<AggregateSymbol, ElementSymbol> projectedMap = new
HashMap<AggregateSymbol, ElementSymbol>();
Iterator<AggregateSymbol> aggIter = aggregates.iterator();
@@ -303,7 +316,7 @@
List<SingleElementSymbol> projectedViewSymbols =
QueryRewriter.deepClone(projectedSymbols, SingleElementSymbol.class);
- SymbolMap viewMapping =
SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource,
NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols);
+ SymbolMap viewMapping =
SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource,
NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols, metadata);
for (AggregateSymbol agg : aggregates) {
agg = (AggregateSymbol)agg.clone();
ExpressionMappingVisitor.mapExpressions(agg, viewMapping.asMap());
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -415,7 +414,7 @@
Criteria crit =
(Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
- Collection elements = getElementsIncriteria(crit);
+ Collection<ElementSymbol> elements = getElementsIncriteria(crit);
boolean removeAps = satisfyAccessPatterns(aps, elements);
if (removeAps) {
@@ -426,8 +425,8 @@
Collections.sort(aps);
}
- static Collection getElementsIncriteria(Criteria crit) {
- Collection elements = new HashSet();
+ static Collection<ElementSymbol> getElementsIncriteria(Criteria crit) {
+ Collection<ElementSymbol> elements = new HashSet<ElementSymbol>();
boolean first = true;
if(crit instanceof CompoundCriteria) {
CompoundCriteria compCrit = (CompoundCriteria) crit;
@@ -450,7 +449,7 @@
* @param elements
* @return
*/
- static boolean satisfyAccessPatterns(List<AccessPattern> aps, Collection
elements) {
+ static boolean satisfyAccessPatterns(List<AccessPattern> aps,
Collection<ElementSymbol> elements) {
for (AccessPattern ap : aps) {
ap.getUnsatisfied().removeAll(elements);
if (ap.getUnsatisfied().isEmpty()) {
@@ -484,39 +483,28 @@
satisfyAccessPatterns(critNode, sourceNode);
SymbolMap symbolMap = (SymbolMap)
sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
-
+ SymbolMap childMap = symbolMap;
+
// Move criteria to first child of union - names are the same, so no symbol mapping
- LinkedList unionChildren = new LinkedList();
+ LinkedList<PlanNode> unionChildren = new LinkedList<PlanNode>();
collectUnionChildren(setOp, unionChildren);
int movedCount = 0;
- Iterator childIter = unionChildren.iterator();
- PlanNode firstChild = (PlanNode) childIter.next();
- GroupSymbol sourceGroup = sourceNode.getGroups().iterator().next();
-
- PlanNode firstBranchNode = NodeEditor.findNodePreOrder(firstChild,
NodeConstants.Types.PROJECT);
-
- if(createConvertedSelectNode(critNode, virtualGroup, firstBranchNode, symbolMap))
{
- movedCount++;
- }
- // Find project cols on first branch
- List firstProjectCols = (List)
firstBranchNode.getProperty(NodeConstants.Info.PROJECT_COLS);
-
- // For each of the remaining children of the union, push separately
- while(childIter.hasNext()) {
- PlanNode childNode = (PlanNode) childIter.next();
-
+ for (PlanNode planNode : unionChildren) {
// Find first project node
- PlanNode projectNode = NodeEditor.findNodePreOrder(childNode,
NodeConstants.Types.PROJECT);
+ PlanNode projectNode = NodeEditor.findNodePreOrder(planNode,
NodeConstants.Types.PROJECT);
- // Create symbol map
- symbolMap = SymbolMap.createSymbolMap(sourceGroup, firstProjectCols, (List)
projectNode.getProperty(NodeConstants.Info.PROJECT_COLS));
+ if (childMap == null) {
+ childMap = SymbolMap.createSymbolMap(symbolMap.getKeys(), (List)
projectNode.getProperty(NodeConstants.Info.PROJECT_COLS));
+ }
// Move the node
- if(createConvertedSelectNode(critNode, virtualGroup, projectNode, symbolMap)) {
+ if(createConvertedSelectNode(critNode, virtualGroup, projectNode, childMap)) {
movedCount++;
}
+
+ childMap = null; //create a new symbol map for the other children
}
//TODO - the logic here could be made more intelligent about EXCEPT and INTERSECT.
@@ -588,7 +576,7 @@
return false;
}
- Collection scalarSubqueries =
ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(converted);
+ Collection<SubqueryContainer> scalarSubqueries =
ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(converted);
if (!scalarSubqueries.isEmpty()){
return false;
}
Modified:
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -113,7 +113,7 @@
// then in the query transformation, this info is used in evaluating/validating
// has criteria/translate criteria clauses
Command transformCmd = getQueryTransformCmd(virtualGroup, metadata);
- Map symbolMap = SymbolMap.createSymbolMap(virtualGroup,
(List<SingleElementSymbol>)transformCmd.getProjectedSymbols()).asMap();
+ Map symbolMap = SymbolMap.createSymbolMap(virtualGroup,
(List<SingleElementSymbol>)transformCmd.getProjectedSymbols(), metadata).asMap();
procCommand.setSymbolMap(symbolMap);
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -551,18 +551,6 @@
return groupInfo;
}
- public static List resolveElements(GroupSymbol group, QueryMetadataInterface
metadata, List elementIDs) throws MetaMatrixComponentException, QueryMetadataException {
- GroupInfo groupInfo = getGroupInfo(group, metadata);
- List result = new ArrayList(elementIDs.size());
- for (Iterator iterator = elementIDs.iterator(); iterator.hasNext();) {
- Object id = iterator.next();
- ElementSymbol symbol = groupInfo.getSymbol(id);
- assert symbol != null;
- result.add(symbol);
- }
- return result;
- }
-
/**
* When access patterns are flattened, they are an approximation the user
* may need to enter as criteria.
@@ -590,11 +578,18 @@
}
while (j.hasNext()) {
List elements = metadata.getElementIDsInAccessPattern(j.next());
- elements = resolveElements(group, metadata, elements);
+ GroupInfo groupInfo = getGroupInfo(group, metadata);
+ List result = new ArrayList(elements.size());
+ for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+ Object id = iterator.next();
+ ElementSymbol symbol = groupInfo.getSymbol(id);
+ assert symbol != null;
+ result.add(symbol);
+ }
if (flatten) {
- accessPatterns.addAll(elements);
+ accessPatterns.addAll(result);
} else {
- accessPatterns.add(new AccessPattern(elements));
+ accessPatterns.add(new AccessPattern(result));
}
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-12-11
22:59:31 UTC (rev 1655)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -26,11 +26,14 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.core.util.Assertion;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -100,27 +103,10 @@
}
public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends
SingleElementSymbol> projectCols) {
- return createSymbolMap(virtualGroup, projectCols, projectCols);
+ List<? extends
SingleElementSymbol> projectCols, QueryMetadataInterface metadata) throws
QueryMetadataException, MetaMatrixComponentException {
+ return createSymbolMap(ResolverUtil.resolveElementsInGroup(virtualGroup,
metadata), projectCols);
}
- public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends
SingleElementSymbol> projectCols,
- List<? extends
SingleElementSymbol> mappedCols) {
- String virtualGroupName = virtualGroup.getName();
- List<ElementSymbol> virtualElements = new
LinkedList<ElementSymbol>();
- for (SingleElementSymbol symbol : projectCols) {
- String name = symbol.getShortName();
- String virtualElementName = virtualGroupName + ElementSymbol.SEPARATOR +
name;
- ElementSymbol virtualElement = new ElementSymbol(virtualElementName);
- virtualElement.setGroupSymbol(virtualGroup);
- virtualElement.setType(symbol.getType());
- virtualElements.add(virtualElement);
- }
-
- return createSymbolMap(virtualElements, mappedCols);
- }
-
public static final SymbolMap createSymbolMap(List<ElementSymbol>
virtualElements,
List<? extends Expression>
mappedCols) {
Assertion.assertTrue(virtualElements.size() == mappedCols.size());
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -48,9 +48,9 @@
super();
// Load some default VDBs
- addVdb(null, null, FakeMetadataFactory.exampleBQT());
- addVdb("bqt", "1", FakeMetadataFactory.exampleBQT());
//$NON-NLS-1$ //$NON-NLS-2$
- addVdb("example1", "1", FakeMetadataFactory.example1());
//$NON-NLS-1$ //$NON-NLS-2$
+ addVdb(null, null, FakeMetadataFactory.exampleBQTCached());
+ addVdb("bqt", "1", FakeMetadataFactory.exampleBQTCached());
//$NON-NLS-1$ //$NON-NLS-2$
+ addVdb("example1", "1",
FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
}
private String getKey(String vdbName, String vdbVersion) {
Modified:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -22,7 +22,7 @@
package com.metamatrix.query.optimizer;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
import com.metamatrix.query.processor.ProcessorPlan;
@@ -31,69 +31,69 @@
import com.metamatrix.query.validator.TestValidator;
-public class TestAccessPatterns extends TestCase {
+public class TestAccessPatterns {
/**
* The virtual access patterns should get satisfied
*/
- public void testVirtualAccessPatternPassing() {
+ @Test public void testVirtualAccessPatternPassing() {
String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1 and
e1='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[]
{"SELECT test.\"group\".e0, test.\"group\".e2 FROM
test.\"group\" WHERE (test.\"group\".e0 = 1) AND
(test.\"group\".e1 = '2')"}); //$NON-NLS-1$
}
- public void testVirtualAccessPatternPassing1() {
+ @Test public void testVirtualAccessPatternPassing1() {
String sql = "delete from vm1.g37 where e1 = 1"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]
{});
}
- public void testVirtualAccessPatternFailing() {
+ @Test public void testVirtualAccessPatternFailing() {
String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1";
//$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testVirtualAccessPatternFailing1() {
+ @Test public void testVirtualAccessPatternFailing1() {
String sql = "delete from vm1.g37"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, null,
null, TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern1() throws Exception {
+ @Test public void testAccessPattern1() throws Exception {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and
e1='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql,
TestValidator.exampleMetadata4(),
new String[] {"SELECT g_0.e0, g_0.e2 FROM
test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')" },
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
}
- public void testAccessPattern2() {
+ @Test public void testAccessPattern2() {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1";
//$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern3() {
+ @Test public void testAccessPattern3() {
String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and
e2='2'"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern4() throws Exception {
+ @Test public void testAccessPattern4() throws Exception {
String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and
e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1 and
e1='2')"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[]
{"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND
(g_0.e1 = '2')"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
//$NON-NLS-1$
}
- public void testAccessPattern5() {
+ @Test public void testAccessPattern5() {
String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and
e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1)";
//$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern6() {
+ @Test public void testAccessPattern6() {
String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM
vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[]
{"SELECT e1, e0, e2 FROM test.\"group\""}); //$NON-NLS-1$
}
- public void testAccessPattern7() {
+ @Test public void testAccessPattern7() {
String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM
vTest.vGroup where e0=1)"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPattern8() {
+ @Test public void testAccessPattern8() {
String sql = "SELECT e0, e2 FROM vTest.vGroup"; //$NON-NLS-1$
TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null,
TestOptimizer.SHOULD_FAIL);
}
@@ -102,7 +102,7 @@
* Tests two access nodes, each with access patterns, but one already
* satisfied by user criteria - the other should be made dependent
*/
- public void testNodesBothHaveAccessPatterns1() throws Exception {
+ @Test public void testNodesBothHaveAccessPatterns1() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1,
pm4.g2 where pm4.g2.e5 = 'abc' and pm4.g1.e1 = pm4.g2.e1",
FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN
(<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 =
'abc'"}, TestOptimizer.getGenericFinder(false),
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"});
//$NON-NLS-1$
@@ -113,7 +113,7 @@
* satisfied by user criteria - the other should be made dependent
* (same query written slightly different).
*/
- public void testNodesBothHaveAccessPatterns1a() throws Exception {
+ @Test public void testNodesBothHaveAccessPatterns1a() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g2,
pm4.g1 where pm4.g2.e1 = pm4.g1.e1 and pm4.g2.e5 = 'abc'",
FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN
(<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 =
'abc'"}, TestOptimizer.getGenericFinder(false),
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"});
//$NON-NLS-1$
@@ -123,7 +123,7 @@
* Self join - tests that both access nodes are satisfied by the select
* criteria (therefore merge join should be used)
*/
- public void testSelfJoinAccessPatterns() throws Exception {
+ @Test public void testSelfJoinAccessPatterns() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1,
pm4.g1 as g1A where pm4.g1.e1 = 'abc' and g1A.e1 = 'abc' and pm4.g1.e2 =
g1A.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g1A.e2 FROM pm4.g1 AS g1A WHERE g1A.e1 =
'abc'", "SELECT pm4.g1.e2, pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 =
'abc'" }, TestOptimizer.getGenericFinder(false),
ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
@@ -145,41 +145,41 @@
});
}
- public void testAccessPatternsFails() {
+ @Test public void testAccessPatternsFails() {
TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2, pm4.g2 as g2A where
pm4.g2.e2 = 123 and pm4.g2.e1 = g2A.e5", FakeMetadataFactory.example1Cached(),
//$NON-NLS-1$
null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testAccessPatternsFails2() {
+ @Test public void testAccessPatternsFails2() {
TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2",
FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
null, null, null,
TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPatternFails() {
+ @Test public void testUnionWithAccessPatternFails() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1
from pm4.g1 where pm4.g1.e2 = 1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPatternFails2() {
+ @Test public void testUnionWithAccessPatternFails2() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1
from pm4.g1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
}
- public void testUnionWithAccessPattern() {
+ @Test public void testUnionWithAccessPattern() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select
pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc'",
FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT
pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testUnionWithAccessPattern2() {
+ @Test public void testUnionWithAccessPattern2() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select
pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc' and pm4.g1.e2 = 1",
FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT
pm4.g1.e1 FROM pm4.g1 WHERE (pm4.g1.e1 = 'abc') AND (pm4.g1.e2 = 1)" });
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testAccessPatternPartialMatch() throws Exception {
+ @Test public void testAccessPatternPartialMatch() throws Exception {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1
= pm4.g2.e1 and pm4.g2.e2 = 123", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
new String[] { "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE (g_0.e2 = 123)
AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS
g_0" }, TestOptimizer.getGenericFinder(false),
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
@@ -190,7 +190,7 @@
* completely different query plan which can't satisfy the access pattern.
* @see #testAccessPatternPartialMatch
*/
- public void testAccessPatternFails3() {
+ @Test public void testAccessPatternFails3() {
TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1
= pm4.g2.e1 or pm4.g2.e2 = 123", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null,
@@ -201,7 +201,7 @@
* Access patterns on models that support joins requires that the access patterns are
satisfied prior to
* RulePlanJoins
*/
- public void testAccessPatternsGroupsInSameModelFails() {
+ @Test public void testAccessPatternsGroupsInSameModelFails() {
TestOptimizer.helpPlan("select pm5.g1.e1 from pm5.g1, pm5.g2 where pm5.g1.e1
= pm5.g2.e1", //$NON-NLS-1$
FakeMetadataFactory.example1Cached(),
null, null, null, TestOptimizer.SHOULD_FAIL);
@@ -211,7 +211,7 @@
// ACCESS PATTERNS
//
==================================================================================
- public void testPushingCriteriaThroughFrameAccessPattern0() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern0() {
TestOptimizer.helpPlan("select * from vm1.g9 where
vm1.g9.e1='abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 =
'abc'", //$NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1
= 'abc'" } ); //$NON-NLS-1$
@@ -220,17 +220,17 @@
/**
* pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
*/
- public void testPushingCriteriaThroughFrameAccessPattern1() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern1() {
TestOptimizer.helpPlan("select * from vm1.g1, vm1.g10 where
vm1.g1.e1='abc' and vm1.g1.e1=vm1.g10.e1",
FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(),
//$NON-NLS-1$
null, TestOptimizer.SHOULD_FAIL );
}
- public void testPushingCriteriaThroughFrameAccessPattern2() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern2() {
TestOptimizer.helpPlan("select e1 from vm1.g11 where
vm1.g11.e1='abc' and vm1.g11.e2=123", FakeMetadataFactory.example1Cached(),
//$NON-NLS-1$
new String[] { "SELECT pm4.g2.e1 FROM pm4.g2 WHERE (pm4.g2.e1 =
'abc') AND (pm4.g2.e2 = 123)" }); //$NON-NLS-1$
}
- public void testPushingCriteriaThroughFrameAccessPattern3() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern3() {
TestOptimizer.helpPlan("select * from vm1.g1, vm1.g9 where
vm1.g1.e1='abc' and vm1.g1.e1=vm1.g9.e1",
FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {"SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 =
'abc'", //$NON-NLS-1$
"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 =
'abc'", //$NON-NLS-1$
@@ -240,7 +240,7 @@
/**
* pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
*/
- public void testPushingCriteriaThroughFrameAccessPattern4() {
+ @Test public void testPushingCriteriaThroughFrameAccessPattern4() {
TestOptimizer.helpPlan("select * from vm1.g10 where
vm1.g10.e1='abc'", FakeMetadataFactory.example1Cached(), null,
TestOptimizer.getGenericFinder(), //$NON-NLS-1$
null, TestOptimizer.SHOULD_FAIL );
}
@@ -248,7 +248,7 @@
/**
* TODO: in this case we should perform a criteria optimization to create set
criteria
*/
- public void testCase6425() {
+ @Test public void testCase6425() {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e1 =
'2'"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -258,7 +258,7 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- public void testCase6425_2() {
+ @Test public void testCase6425_2() {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR (e1 =
'2' AND e2 = 3)"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -268,7 +268,7 @@
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
- public void testCase6425_4() throws Exception {
+ @Test public void testCase6425_4() throws Exception {
String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e2 =
'2'"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -279,7 +279,7 @@
/*
* Criteria was preventing rule choose dependent from creating the appropriate
dependent join
*/
- public void testMultiAccessPatternWithCriteria() throws Exception {
+ @Test public void testMultiAccessPatternWithCriteria() throws Exception {
String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 =
pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' "; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Modified:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -23,7 +23,6 @@
package com.metamatrix.query.optimizer;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -41,7 +40,6 @@
import com.metamatrix.query.processor.relational.RelationalNode;
import com.metamatrix.query.processor.relational.RelationalPlan;
import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
import com.metamatrix.query.unittest.FakeMetadataFacade;
@@ -137,13 +135,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestOptimizer.helpGetCommand("select pm1.g1.e1 from
pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(),
Collections.EMPTY_LIST); //$NON-NLS-1$
-
- Option option = new Option();
- option.addDependentGroup("pm2.g1"); //$NON-NLS-1$
- command.setOption(option);
-
- ProcessorPlan plan = TestOptimizer.helpPlanCommand(command,
FakeMetadataFactory.example1Cached(), capFinder,
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1,
pm2.g1 where pm1.g1.e1 = pm2.g1.e1 option makedep pm2.g1",
FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e1 IN
(<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" },
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
checkDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
@@ -173,11 +165,9 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestOptimizer.helpGetCommand("select pm1.g1.e1, pm2.g1.e1
from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1",
FakeMetadataFactory.example1Cached(), Collections.EMPTY_LIST); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1, pm2.g1.e1
from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1",
FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN
(<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" },
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- ProcessorPlan plan = TestOptimizer.helpPlanCommand(command,
FakeMetadataFactory.example1Cached(), capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN
(<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" },
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
checkNotDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
TestOptimizer.checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -22,44 +22,72 @@
package com.metamatrix.query.optimizer;
+import static com.metamatrix.query.optimizer.TestOptimizer.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
+import org.junit.Test;
+import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
-public class TestInlineView extends TestCase {
+public class TestInlineView {
+
+ public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder
capFinder) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
- public void testANSIJoinInlineView() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ caps.setFunctionSupport("case", true); //$NON-NLS-1$
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ return metadata;
+ }
+
+ @Test public void testANSIJoinInlineView() throws Exception {
runTest(createANSIJoinInlineView());
}
- public void testInlineView() throws Exception {
+ @Test public void testInlineView() throws Exception {
runTest(createInlineView());
}
- public void testInlineViewWithDistinctAndOrderBy() throws Exception {
+ @Test public void testInlineViewWithDistinctAndOrderBy() throws Exception {
runTest(createInlineViewWithDistinctAndOrderBy());
}
- public void testInlineViewOfVirtual() throws Exception{
+ @Test public void testInlineViewOfVirtual() throws Exception{
runTest(createInlineViewOfVirtual());
}
- public void testInlineViewWithOuterOrderAndGroup() throws Exception {
+ @Test public void testInlineViewWithOuterOrderAndGroup() throws Exception {
runTest(createInlineViewWithOuterOrderAndGroup());
}
- public void testInlineViewsInUnions() throws Exception {
+ @Test public void testInlineViewsInUnions() throws Exception {
runTest(crateInlineViewsInUnions());
}
- public void testUnionInInlineView() throws Exception{
+ @Test public void testUnionInInlineView() throws Exception{
runTest(createUnionInInlineView());
}
@@ -83,8 +111,6 @@
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineView() throws Exception {
String userQuery = "select
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
from (select count(bqt1.smalla.intkey) as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey)
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
bqt1.smallb " + //$NON-NLS-1$
@@ -106,8 +132,6 @@
return new InlineViewCase("testInlineView", userQuery, optimizedQuery,
//$NON-NLS-1$
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineViewWithDistinctAndOrderBy() throws Exception
{
String userQuery = "select Q1.a from (select distinct count(bqt1.smalla.intkey) as
a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by
bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a =
1 and q1.a + q1.intkey = 2"; //$NON-NLS-1$
@@ -130,7 +154,6 @@
}
-
public static InlineViewCase createInlineViewOfVirtual() throws Exception{
String userQuery = "select q1.A from (select count(intkey) as a, intkey, stringkey
from vqt.smalla group by intkey, stringkey) q1 inner join vqt.smallb as q2 on q1.intkey =
q2.a12345 where q1.a = 2"; //$NON-NLS-1$
String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.IntKey AS c_0,
COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.StringKey HAVING
COUNT(g_0.IntKey) = 2) AS v_0, BQT1.SmallA AS g_1 WHERE v_0.c_0 = Concat(g_1.StringKey,
g_1.StringNum)"; //$NON-NLS-1$
@@ -147,8 +170,6 @@
return new InlineViewCase("testInlineViewOfVirtual", userQuery,
optimizedQuery, //$NON-NLS-1$
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase createInlineViewWithOuterOrderAndGroup() throws Exception
{
String userQuery = "select count(Q1.a) b from (select distinct
count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on
q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by
b"; //$NON-NLS-1$
@@ -170,8 +191,6 @@
sourceQueries, expectedResults);
}
-
-
public static InlineViewCase crateInlineViewsInUnions() throws Exception {
String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a,
bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join
bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a)
b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from
bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join
bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group
by Q1.a order by b)"; //$NON-NLS-1$
String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM
bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN
bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM
(SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP
BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1))
AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0";
//$NON-NLS-1$
@@ -196,8 +215,6 @@
}
-
-
public static InlineViewCase createUnionInInlineView() throws Exception{
String userQuery = "select t1.intkey from (select case when q1.a=1 then 2 else
1 end as a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from
bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a =
bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select
distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on
q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b))
as q3, bqt1.smallb as t1 where q3.a = t1.intkey order by t1.intkey"; //$NON-NLS-1$
@@ -228,7 +245,7 @@
protected void runTest(InlineViewCase testCase) throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = TestOptimizer.createInlineViewMetadata(capFinder);
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null,
capFinder, new String[] {testCase.optimizedQuery},
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -236,4 +253,60 @@
TestOptimizer.checkSubPlanCount(plan, 0);
}
+
+ @Test public void testAliasCreationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select a, b from (select distinct
count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by
bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT
DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM
bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkSubPlanCount(plan, 0);
+ }
+
+ @Test public void testAliasPreservationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select
count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by
bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b
FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla
GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS
q1"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkSubPlanCount(plan, 0);
+ }
+
+ /**
+ * Order by's will be added to the atomic queries
+ */
+ @Test public void testCrossSourceInlineView() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select * from (select
count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a,
bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey =
q2.intkey where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1
FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY
g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT v_0.c_0, v_0.c_1
FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY
g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ checkSubPlanCount(plan, 0);
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -28,7 +28,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -182,13 +181,13 @@
throw new MetaMatrixRuntimeException(err);
}
- return helpPlanCommand(command, md, capFinder, expectedAtomic, shouldSucceed ?
ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic,
shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING :
ComparisonMode.FAILED_PLANNING);
}
public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List
bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode)
throws QueryParserException, QueryResolverException, QueryValidatorException,
MetaMatrixComponentException {
Command command = helpGetCommand(sql, md, bindings);
- return helpPlanCommand(command, md, capFinder, expectedAtomic, mode);
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, mode);
}
@@ -218,13 +217,13 @@
return command;
}
- public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface
md, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) {
+ public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface
md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, String[] expectedAtomic,
ComparisonMode mode) {
if (capFinder == null){
capFinder = getGenericFinder();
}
// Collect atomic queries
- ProcessorPlan plan = getPlan(command, md, capFinder, mode !=
ComparisonMode.FAILED_PLANNING);
+ ProcessorPlan plan = getPlan(command, md, capFinder, analysisRecord, mode !=
ComparisonMode.FAILED_PLANNING);
if (mode == ComparisonMode.CORRECTED_COMMAND_STRING) {
checkAtomicQueries(expectedAtomic, plan, md, capFinder);
@@ -237,14 +236,14 @@
public static void checkAtomicQueries(String[] expectedAtomic,
ProcessorPlan plan) {
- Set actualQueries = getAtomicQueries(plan);
+ Set<String> actualQueries = getAtomicQueries(plan);
if (actualQueries.size() != 1 || expectedAtomic.length != 1) {
// Compare atomic queries
HashSet<String> expectedQueries = new
HashSet<String>(Arrays.asList(expectedAtomic));
assertEquals("Did not get expected atomic queries: ",
expectedQueries, actualQueries); //$NON-NLS-1$
} else {
- assertEquals("Did not get expected atomic query: ",
expectedAtomic[0], (String)actualQueries.iterator().next()); //$NON-NLS-1$
+ assertEquals("Did not get expected atomic query: ",
expectedAtomic[0], actualQueries.iterator().next()); //$NON-NLS-1$
}
}
@@ -274,10 +273,12 @@
assertEquals("Did not get expected atomic queries: ", expectedQueries,
actualQueries); //$NON-NLS-1$
}
- public static ProcessorPlan getPlan(Command command, QueryMetadataInterface md,
CapabilitiesFinder capFinder, boolean shouldSucceed) {
+ static ProcessorPlan getPlan(Command command, QueryMetadataInterface md,
CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, boolean shouldSucceed) {
// plan
ProcessorPlan plan = null;
- AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
+ if (analysisRecord == null) {
+ analysisRecord = new AnalysisRecord(false, false, DEBUG);
+ }
if (shouldSucceed) {
try {
//do planning
@@ -318,27 +319,22 @@
return plan;
}
- public static Set getAtomicQueries(ProcessorPlan plan) {
- Iterator atomicQueries = getAtomicCommands(plan).iterator();
+ public static Set<String> getAtomicQueries(ProcessorPlan plan) {
+ Set<Command> atomicQueries = new HashSet<Command>();
+ if(plan instanceof RelationalPlan) {
+ getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
+ }
- Set stringQueries = new HashSet();
+ Set<String> stringQueries = new HashSet<String>();
- while (atomicQueries.hasNext()) {
- stringQueries.add(atomicQueries.next().toString());
+ for (Command command : atomicQueries) {
+ stringQueries.add(command.toString());
}
return stringQueries;
}
- public static Set getAtomicCommands(ProcessorPlan plan) {
- Set atomicQueries = new HashSet();
- if(plan instanceof RelationalPlan) {
- getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
- }
- return atomicQueries;
- }
-
- private static void getAtomicCommands(RelationalNode node, Set atomicQueries) {
+ private static void getAtomicCommands(RelationalNode node, Set<Command>
atomicQueries) {
if(node instanceof AccessNode) {
AccessNode accessNode = (AccessNode) node;
atomicQueries.add( accessNode.getCommand());
@@ -397,7 +393,7 @@
* @param relationalNode
* @return int[]
*/
- public static void collectCounts(RelationalNode relationalNode, int[] counts,
Class<?>[] types) {
+ static void collectCounts(RelationalNode relationalNode, int[] counts,
Class<?>[] types) {
Class<?> nodeType = relationalNode.getClass();
if(nodeType.equals(JoinNode.class)) {
JoinStrategy strategy = ((JoinNode)relationalNode).getJoinStrategy();
@@ -608,7 +604,7 @@
new String[] { "e1", "e2", "e3", "e4" },
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE });
List vm1g4e = FakeMetadataFactory.createElements(vm1g4,
- new String[] { "e1", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING });
List vm1g5e = FakeMetadataFactory.createElements(vm1g5,
new String[] { "e1" }, //$NON-NLS-1$
@@ -4262,8 +4258,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1",
//$NON-NLS-1$
@@ -4282,8 +4277,7 @@
caps.setCapabilitySupport(Capability.QUERY_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE e1 WHEN 'a' THEN 10 ELSE (e2+0) END FROM
pm1.g1", //$NON-NLS-1$
@@ -4318,8 +4312,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1",
//$NON-NLS-1$
@@ -4338,8 +4331,7 @@
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(
"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE (e2+0) END FROM
pm1.g1", //$NON-NLS-1$
@@ -4840,7 +4832,7 @@
ProcessorPlan subplan = (ProcessorPlan) subplans.iterator().next();
// Collect atomic queries
- Set actualQueries = getAtomicQueries(subplan);
+ Set<String> actualQueries = getAtomicQueries(subplan);
// Compare atomic queries
HashSet<String> expectedQueries = new
HashSet<String>(Arrays.asList(new String[] { "SELECT bqt1.smalla.datevalue FROM
bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smalla.intkey) AND (bqt1.smalla.stringkey =
bqt1.smalla.stringkey)"})); //$NON-NLS-1$
@@ -5770,7 +5762,7 @@
ProcessorPlan plan = helpPlan(
"select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in
(select e2 from vm1.g1)", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT g_1.e1, g_3.e1 FROM
pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND
(g_0.e2 = g_1.e2) AND (g_1.e1 = g_3.e1) AND (g_1.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS
g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT g_0.e1, g_2.e1 FROM
pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND
(g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS
g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -5851,72 +5843,7 @@
ComparisonMode.EXACT_COMMAND_STRING );
}
-
- public static FakeMetadataFacade createInlineViewMetadata(FakeCapabilitiesFinder
capFinder) {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- caps.setFunctionSupport("case", true); //$NON-NLS-1$
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- return metadata;
- }
- /**
- * Order by's will be added to the atomic queries
- */
- @Test public void testCrossSourceInlineView() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select * from (select
count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by
bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a,
bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey =
q2.intkey where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1
FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY
g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT v_0.c_0, v_0.c_1
FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY
g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- checkSubPlanCount(plan, 0);
- }
-
- @Test public void testAliasPreservationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select
count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by
bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b
FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla
GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS
q1"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
- }
-
//since this does not support convert, it should not be collapsed
@Test public void testBadCollapseUnion() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -5950,7 +5877,7 @@
}
@Test public void testCase3966() {
- ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4)
values('test', 1, convert('true', boolean) , convert('12', double)
)", FakeMetadataFactory.example1(), //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4)
values('test', 1, convert('true', boolean) , convert('12', double)
)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {} );
checkNodeTypes(plan, new int[] {
@@ -6655,19 +6582,7 @@
checkNodeTypes(plan, FULL_PUSHDOWN);
}
-
- @Test public void testAliasCreationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = createInlineViewMetadata(capFinder);
- ProcessorPlan plan = helpPlan("select a, b from (select distinct
count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by
bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT
DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM
bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkSubPlanCount(plan, 0);
- }
-
@Test public void testCase6364() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
@@ -6821,6 +6736,6 @@
TestOptimizer.SHOULD_SUCCEED);
}
- private static final boolean DEBUG = false;
+ public static final boolean DEBUG = false;
}
Added:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
(rev 0)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.query.optimizer.relational;
+
+import static com.metamatrix.query.optimizer.TestOptimizer.*;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestMaterialization {
+
+ @Test public void testMaterializedTransformation() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations);
//$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1);
//$NON-NLS-1$
+ assertEquals("Expected catagory mat view",
((QueryAnnotation)annotations.iterator().next()).getCategory(),
QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Ignore("we no longer auto detect this case, if we need this logic it will have
to be added to the rewriter since it changes select into to an insert")
+ @Test public void testMaterializedTransformationLoading() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM
MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations);
//$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1);
//$NON-NLS-1$
+ assertEquals("Expected catagory mat view",
((QueryAnnotation)annotations.iterator().next()).getCategory(),
QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testMaterializedTransformationNoCache() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE
MatView.MatView"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations);
//$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1);
//$NON-NLS-1$
+ assertEquals("Expected catagory mat view",
((QueryAnnotation)annotations.iterator().next()).getCategory(),
QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ //related to defect 14423
+ @Test public void testMaterializedTransformationNoCache2() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE";
//$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations);
//$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1);
//$NON-NLS-1$
+ assertEquals("Expected catagory mat view",
((QueryAnnotation)annotations.iterator().next()).getCategory(),
QueryAnnotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheInTransformation() throws Exception {
+ String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"},
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testTableNoCacheDoesntCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache
matview.matview1"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 =
'1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache";
//$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(false, true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis,
new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x =
'1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+}
Property changes on:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -22,10 +22,13 @@
package com.metamatrix.query.optimizer.relational.rules;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Collection;
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.teiid.dqp.internal.process.TestPreparedStatement;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -51,31 +54,14 @@
/**
* Tests {@link RuleChooseAccessPattern}
*/
-public class TestRuleAccessPatternValidation extends TestCase {
+public class TestRuleAccessPatternValidation {
- private static final FakeMetadataFacade METADATA = FakeMetadataFactory.example1();
+ private static final FakeMetadataFacade METADATA =
FakeMetadataFactory.example1Cached();
- private PlanHints planHints;
-
private static final boolean DEBUG = false;
- private static CapabilitiesFinder FINDER = new
DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());;
+ private static CapabilitiesFinder FINDER = new
DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities());
- // ################################## FRAMEWORK ################################
-
- /**
- * Constructor for TestRuleChooseAccessPattern.
- */
- public TestRuleAccessPatternValidation(String name) {
- super(name);
- }
-
- public void setUp() {
- this.planHints = new PlanHints();
- }
-
- // ################################## TEST HELPERS ################################
-
/**
* @param command the query to be turned into a test query plan
* @param expectedChosenPredicates expected criteria predicates that should
@@ -112,7 +98,7 @@
p.initialize(query, null, METADATA, FINDER, null, null);
PlanNode planNode = p.generatePlan(query);
- final RuleStack rules = RelationalPlanner.buildRules(planHints);
+ final RuleStack rules = RelationalPlanner.buildRules(new PlanHints());
PlanNode testPlan = helpExecuteRules(rules, planNode, METADATA, DEBUG);
@@ -149,7 +135,7 @@
* This test demonstrates that APs are ignored for inserts
* CASE 3966
*/
- public void testInsertWithAccessPattern_Case3966() throws Exception {
+ @Test public void testInsertWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "insert into pm4.g1 (e1, e2, e3, e4)
values('test', 1, convert('true', boolean) , convert('12', double)
)" ); //$NON-NLS-1$
}
@@ -157,7 +143,7 @@
* This test demonstrates that a satisfied AP does not fail.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "delete from pm4.g1 where e1 =
'test' and e2 = 1" ); //$NON-NLS-1$
}
@@ -165,7 +151,7 @@
* This test demonstrates that unsatisfied AP fails.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966_2() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966_2() throws Exception {
try {
this.helpTestAccessPatternValidation( "delete from pm4.g1" );
//$NON-NLS-1$
fail("Expected QueryPlannerException, but did not get one");
//$NON-NLS-1$
@@ -177,7 +163,7 @@
}
}
- public void testUpdateWithAccessPattern_Case3966() throws Exception {
+ @Test public void testUpdateWithAccessPattern_Case3966() throws Exception {
this.helpTestAccessPatternValidation( "update pm4.g1 set e1 =
'test1' where e1 = 'test' and e2 = 1" ); //$NON-NLS-1$
}
@@ -185,7 +171,7 @@
* This test demonstrates that unsatisfied AP fails.
* Found testing fix for 3966.
*/
- public void testUpdateWithAccessPattern_Case3966_2() throws Exception {
+ @Test public void testUpdateWithAccessPattern_Case3966_2() throws Exception {
try {
this.helpTestAccessPatternValidation( "update pm4.g1 set e1 =
'test'" ); //$NON-NLS-1$
fail("Expected QueryPlannerException, but did not get one");
//$NON-NLS-1$
@@ -201,7 +187,7 @@
* This test demonstrates that APs are ignored for inserts through a virtual layer
* CASE 3966
*/
- public void testInsertWithAccessPattern_Case3966_VL() throws Exception {
+ @Test public void testInsertWithAccessPattern_Case3966_VL() throws Exception {
this.helpTestAccessPatternValidation( "insert into vm1.g37 (e1, e2, e3, e4)
values('test', 1, convert('true', boolean) , convert('12', double)
)" ); //$NON-NLS-1$
}
@@ -210,7 +196,7 @@
* through a virtual layer does not fail.
* Found testing fix for 3966.
*/
- public void testDeleteWithAccessPattern_Case3966_VL() throws Exception {
+ @Test public void testDeleteWithAccessPattern_Case3966_VL() throws Exception {
this.helpTestAccessPatternValidation( "delete from vm1.g37 where e1 =
'test' and e2 = 1" ); //$NON-NLS-1$
}
}
Modified:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -71,7 +71,7 @@
/* Make Neither Side Dependent */
private static final int NEITHER_SIDE = 3;
- private FakeMetadataFacade metadata;
+ private FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
// ################################## FRAMEWORK ################################
@@ -79,15 +79,6 @@
super(name);
}
- public void setUp() {
- // set up resolver metadata
- metadata = FakeMetadataFactory.example1();
- }
-
- public void tearDown() {
- metadata = null;
- }
-
// ################################## TEST HELPERS ################################
public PlanNode createAccessNode(Collection groupSymbols) {
Modified:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -26,8 +26,6 @@
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
@@ -41,7 +39,7 @@
public class TestRulePlaceAccess extends TestCase {
- private static final QueryMetadataInterface METADATA =
FakeMetadataFactory.example1();
+ private static final QueryMetadataInterface METADATA =
FakeMetadataFactory.example1Cached();
// ################################## FRAMEWORK ################################
@@ -58,7 +56,7 @@
* Object element ids) for a physical group will be found and added
* as a property of an ACCESS node.
*/
- public void testAddAccessPatterns2(){
+ public void testAddAccessPatterns2() throws Exception {
Query query = new Query();
From from = new From();
@@ -70,31 +68,17 @@
select.addSymbol(new AllSymbol());
query.setSelect(select);
- try {
- group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
- } catch (QueryMetadataException e) {
- fail(e.getMessage());
- } catch (MetaMatrixComponentException e) {
- fail(e.getMessage());
- }
+ group.setMetadataID(METADATA.getGroupID("pm4.g2")); //$NON-NLS-1$
PlanNode n1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
n1.setProperty(NodeConstants.Info.ATOMIC_REQUEST, query);
n1.addGroup(group);
- try {
- RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
- } catch (QueryMetadataException e) {
- fail(e.getMessage());
- } catch (MetaMatrixComponentException e) {
- fail(e.getMessage());
- }
+ RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
Collection accessPatterns =
(Collection)n1.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
assertNotNull(accessPatterns);
assertTrue("Expected two access patterns, got " +
accessPatterns.size(), accessPatterns.size() == 2); //$NON-NLS-1$
-// assertTrue(accessPatterns.contains(FakeMetadata.ELEMENT_IDS_1));
-// assertTrue(accessPatterns.contains(FakeMetadata.ELEMENT_IDS_2));
}
Modified:
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -32,6 +32,9 @@
import org.junit.Test;
import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import com.metamatrix.query.optimizer.relational.RelationalPlanner;
@@ -46,7 +49,6 @@
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.util.CommandContext;
@@ -65,7 +67,7 @@
}
@Test public void testPushAcrossFrameWithAccessNode() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ QueryMetadataInterface metadata = new
TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore());
Command command = TestOptimizer.helpGetCommand("select * from (select * from
pm1.g1 union select * from pm1.g2) x where e1 = 1", metadata, null); //$NON-NLS-1$
Command subCommand = TestOptimizer.helpGetCommand("select * from pm1.g1 union
select * from pm1.g2", metadata, null); //$NON-NLS-1$
RelationalPlanner p = new RelationalPlanner();
@@ -74,7 +76,7 @@
PlanNode child = p.generatePlan(subCommand);
PlanNode sourceNode = NodeEditor.findNodePreOrder(root,
NodeConstants.Types.SOURCE);
sourceNode.addFirstChild(child);
- sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP,
SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(),
(List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS)));
+ sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP,
SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(),
(List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS),
metadata));
//add a dummy access node
PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
accessNode.addGroups(child.getFirstChild().getGroups());
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -642,7 +642,7 @@
// Slightly modify metadata to set max set size to just a few rows - this
// will allow us to test the dependent overflow case
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
@@ -711,8 +711,6 @@
capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- // Slightly modify metadata to set max set size to just a few rows - this
- // will allow us to test the dependent overflow case
FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
Command command = TestProcessor.helpParse(sql);
Modified:
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -100,7 +100,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -259,7 +259,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -340,7 +340,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager();
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -481,9 +481,8 @@
} );
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() +
"): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -505,9 +504,8 @@
new List[] {
Arrays.asList(new Object[] { new Integer(1) }),
} );
- }catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() +
"): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }catch(MetaMatrixException e) {
+ throw new RuntimeException(e);
}
}
@@ -1990,7 +1988,7 @@
sampleData1(dataManager);
// Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1());
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
// Run query
helpProcess(plan, dataManager, expected);
@@ -3915,7 +3913,7 @@
sampleData1(dataManager);
// Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1());
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
// Run query
helpProcess(plan, dataManager, expected);
@@ -6515,7 +6513,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Command command = helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
Modified:
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-11
22:59:31 UTC (rev 1655)
+++
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-11
23:05:15 UTC (rev 1656)
@@ -237,7 +237,7 @@
QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g1 = createUpdatableVirtualGroup("vm1.g1", vm1,
vm1g1n1); //$NON-NLS-1$
- QueryNode vm2g1n1 = new QueryNode("vm2.g1", "SELECT * FROM pm1.g1,
pm1.g2 where pm1.g1.e2 = pm1.g2.e2"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm2g1n1 = new QueryNode("vm2.g1", "SELECT pm1.g1.* FROM
pm1.g1, pm1.g2 where pm1.g1.e2 = pm1.g2.e2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm2g1 =
FakeMetadataFactory.createUpdatableVirtualGroup("vm2.g1", vm2, vm2g1n1);
//$NON-NLS-1$
QueryNode vm1g1n1_defect10711 = new QueryNode("vm1.g1a", "SELECT *
FROM vm1.g1 as X"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -405,8 +405,8 @@
new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER });
List vm1g11e = createElements(vm1g11,
- new String[] { "e1", "e2", "e3", "e4"
}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE });
+ new String[] { "e1", "e2", "e3",
"e4", "e5", "e6"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER });
List vm1g12e = createElements(vm1g12,
new String[] { "e1", "e2", "e3", "e4"
}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE });
@@ -480,8 +480,8 @@
new String[] { "ve1", "ve2" }, //$NON-NLS-1$
//$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.STRING });
List vm1g37e = createElements(vm1g37,
- new String[] { "e1", "e2", "e3",
"e4", "e5" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
//$NON-NLS-5$
- new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.DOUBLE });
+ new String[] { "e1", "e2", "e3",
"e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE });
List vm1g38e = createElements(vm1g38,
new String[] { "e1", "e2" }, //$NON-NLS-1$
//$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER });
@@ -1008,7 +1008,7 @@
FakeMetadataObject vgvp6e4 =
FakeMetadataFactory.createElement("vm1.vgvp6.ve4", vgvp6,
DataTypeManager.DefaultDataTypes.INTEGER, 3); //$NON-NLS-1$
//virtual group with two elements. One selectable, one not.
- QueryNode vm1g35n1 = new QueryNode("vm1.g35", "SELECT e2 FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g35n1 = new QueryNode("vm1.g35", "SELECT e1, e2 FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g35 = createVirtualGroup("vm1.g35", vm1, vm1g35n1);
//$NON-NLS-1$
FakeMetadataObject vm1g35e1 =
FakeMetadataFactory.createElement("vm1.g35.e1", vm1g35,
DataTypeManager.DefaultDataTypes.STRING, 1); //$NON-NLS-1$
vm1g35e1.putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
@@ -2007,7 +2007,7 @@
QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM
vm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g1 = createUpdatableVirtualGroup("vm1.g1", vm1,
vm1g1n1); //$NON-NLS-1$
- QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1,
pm1.g2.e2, pm1.g2.e3 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1,
pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g2 = createUpdatableVirtualGroup("vm1.g2", vm1,
vm1g2n1); //$NON-NLS-1$
// Create virtual elements
@@ -2016,9 +2016,9 @@
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE },
new Object[] { "xyz", Integer.getInteger("123"),
Boolean.valueOf("true"), Double.valueOf("123.456")}); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
List vm1g2e = createElementsWithDefaults(vm1g2,
- new String[] { "e1", "e2", "e3" },
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN },
- new Object[] { "abc", Integer.getInteger("456"),
Boolean.valueOf("false")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { "e1", "e2", "e3", "e4"
}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN,
DataTypeManager.DefaultDataTypes.DOUBLE },
+ new Object[] { "abc", Integer.getInteger("456"),
Boolean.valueOf("false"), null}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vm1g1.putProperty(procedureType, procedure1);
vm1g2.putProperty(procedureType, procedure2);
@@ -3302,12 +3302,22 @@
new String[] { "e1" }, //$NON-NLS-1$
new String[] {
DataTypeManager.DefaultDataTypes.STRING});
+ FakeMetadataObject physGroup1 =
createPhysicalGroup("MatTable.MatTable1", physModel); //$NON-NLS-1$
+ List physElements1 = createElements(physGroup,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] {
DataTypeManager.DefaultDataTypes.STRING});
+
+ FakeMetadataObject physGroupStage1 =
createPhysicalGroup("MatTable.MatStage1", physModel); //$NON-NLS-1$
+ List physStageElements1 = createElements(physGroupStage,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] {
DataTypeManager.DefaultDataTypes.STRING});
+
FakeMetadataObject physGroup_virtSrc =
createPhysicalGroup("MatSrc.MatSrc", physModel_virtSrc); //$NON-NLS-1$
List physElements_virtSrc = createElements(physGroup_virtSrc,
new String[] { "X" }, //$NON-NLS-1$
new String[] {
DataTypeManager.DefaultDataTypes.STRING});
- QueryNode virtTrans = new QueryNode("MatView.MatView", "SELECT x
FROM MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode virtTrans = new QueryNode("MatView.MatView", "SELECT x
as e1 FROM MatSrc.MatSrc"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject virtGroup = createVirtualGroup("MatView.MatView",
virtModel, virtTrans); //$NON-NLS-1$
List virtElements = createElements(virtGroup,
new String[] { "e1" }, //$NON-NLS-1$
@@ -3323,6 +3333,15 @@
new String[] { "e1" }, //$NON-NLS-1$
new String[] {
DataTypeManager.DefaultDataTypes.STRING});
+ QueryNode virtTrans1 = new QueryNode("MatView.MatView1", "SELECT
e1 FROM MatView.MatView where e1 = 1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject virtGroup1 = createVirtualGroup("MatView.MatView1",
virtModel, virtTrans1); //$NON-NLS-1$
+ List virtElements1 = createElements(virtGroup1,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] {
DataTypeManager.DefaultDataTypes.STRING});
+
+ virtGroup1.putProperty(FakeMetadataObject.Props.MAT_GROUP, physGroup1);
+ virtGroup1.putProperty(FakeMetadataObject.Props.MAT_STAGE, physGroupStage1);
+
FakeMetadataStore store = new FakeMetadataStore();
store.addObject(virtModel);
store.addObject(physModel);
@@ -3331,13 +3350,18 @@
store.addObjects(physElements);
store.addObject(physGroupStage);
store.addObjects(physStageElements);
+ store.addObject(physGroup1);
+ store.addObjects(physElements1);
+ store.addObject(physGroupStage1);
+ store.addObjects(physStageElements1);
store.addObject(physGroup_virtSrc);
store.addObjects(physElements_virtSrc);
store.addObject(virtGroup);
store.addObjects(virtElements);
store.addObject(vGroup);
store.addObjects(vElements);
-
+ store.addObject(virtGroup1);
+ store.addObjects(virtElements1);
return new FakeMetadataFacade(store);
}