[teiid-commits] teiid SVN: r829 - in trunk: connector-api/src/main/java/org/teiid/connector/basic and 12 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Apr 23 11:33:20 EDT 2009


Author: shawkins
Date: 2009-04-23 11:33:20 -0400 (Thu, 23 Apr 2009)
New Revision: 829

Removed:
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java
Modified:
   trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java
   trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java
   trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java
   trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
   trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
   trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
   trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
Log:
TEIID-203 adding the supportsGroupBy capability and consolidating resolvervisitorutil and resolverutil.

Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorCapabilities.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -395,4 +395,10 @@
      */
     boolean supportsBulkInsert();
     
+    /**
+     * Whether the source supports an explicit GROUP BY clause
+     * @since 6.0
+     */
+    boolean supportsGroupBy();
+    
 }

Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicConnectorCapabilities.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -430,4 +430,9 @@
 	public boolean supportsBulkInsert() {
 		return false;
 	}
+	
+	@Override
+	public boolean supportsGroupBy() {
+		return false;
+	}
 }

Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCCapabilities.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -59,6 +59,11 @@
     public void setMaxInCriteriaSize(int maxInCriteriaSize) {
         this.maxInCriteriaSize = maxInCriteriaSize;
     }
+    
+    @Override
+    public boolean supportsGroupBy() {
+    	return true;
+    }
 
     /* 
      * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregates()

Modified: trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java
===================================================================
--- trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackCapabilities.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -67,6 +67,11 @@
         });
         return functions;
     }
+    
+    @Override
+    public boolean supportsGroupBy() {
+    	return true;
+    }
 
     /* 
      * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregates()

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -57,7 +57,10 @@
     }
     
     public void setCapabilitySupport(Capability capability, boolean supports) {
-        capabilityMap.put(capability, Boolean.valueOf(supports));
+    	if (supports && capability == Capability.QUERY_AGGREGATES) {
+    		capabilityMap.put(Capability.QUERY_GROUP_BY, true);
+    	}
+        capabilityMap.put(capability, supports);
     } 
 
     public void setFunctionSupport(String function, boolean supports) {        

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -373,7 +373,11 @@
         /**
          * @since 6.0.0 indicates support for where all
          */
-        REQUIRES_CRITERIA
+        REQUIRES_CRITERIA,
+        /**
+         * @since 6.1.0 indicates support for GROUP BY
+         */
+        QUERY_GROUP_BY
     }
 
     public enum Scope {

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -139,10 +139,12 @@
         if (!caps.supportsCapability(Capability.QUERY_AGGREGATES)) {
             return false;
         }
-        
-        boolean supportsFunctionsInGroupBy = caps.supportsCapability(Capability.QUERY_FUNCTIONS_IN_GROUP_BY);
+        if (groupCols != null && !groupCols.isEmpty()) {
+        	if (!caps.supportsCapability(Capability.QUERY_GROUP_BY)) {
+        		return false;
+        	}
+            boolean supportsFunctionsInGroupBy = caps.supportsCapability(Capability.QUERY_FUNCTIONS_IN_GROUP_BY);
 
-        if(groupCols != null) {
             // Also verify that if there is a function that we can support pushdown of functions in group by
             Iterator colIter = groupCols.iterator();
             while(colIter.hasNext()) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -44,7 +44,7 @@
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
+import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.rewriter.QueryRewriter;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.lang.Command;
@@ -151,7 +151,7 @@
         QueryNode queryNode = null;
         try {
             GroupSymbol gs = new GroupSymbol(groupName);
-            ResolverVisitorUtil.resolveGroup(gs, metadata);
+            ResolverUtil.resolveGroup(gs, metadata);
             queryNode = metadata.getVirtualPlan(gs.getMetadataID());
         } catch (QueryResolverException e) {
             throw new QueryPlannerException(e, ErrorMessageKeys.OPTIMIZER_0029, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0029, groupName));
@@ -179,7 +179,7 @@
     public static GroupSymbol createResolvedGroup(GroupSymbol group, QueryMetadataInterface metadata) 
         throws MetaMatrixComponentException {
         try {
-            ResolverVisitorUtil.resolveGroup(group, metadata);
+            ResolverUtil.resolveGroup(group, metadata);
             return group;
         } catch (QueryResolverException e) {
             throw new MetaMatrixComponentException(e);

Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -54,7 +54,6 @@
 import com.metamatrix.query.processor.relational.RelationalNode;
 import com.metamatrix.query.processor.relational.RelationalPlan;
 import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.rewriter.QueryRewriter;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Criteria;
@@ -382,7 +381,7 @@
         throws QueryResolverException,QueryMetadataException,MetaMatrixComponentException {
         
         GroupSymbol oldGroupSymbol = new GroupSymbol(oldGroup);
-        ResolverVisitorUtil.resolveGroup(oldGroupSymbol, metadata);
+        ResolverUtil.resolveGroup(oldGroupSymbol, metadata);
         
         HashSet projectedElements = new HashSet(ResolverUtil.resolveElementsInGroup(oldGroupSymbol, metadata));
         

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -39,7 +39,6 @@
 import com.metamatrix.query.metadata.TempMetadataStore;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.sql.ProcedureReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.GroupContext;
@@ -219,7 +218,7 @@
                                                             QueryResolverException {
         // Resolve group so we can tell whether it is an update procedure
         GroupSymbol group = procCommand.getGroup();
-        ResolverVisitorUtil.resolveGroup(group, metadata);
+        ResolverUtil.resolveGroup(group, metadata);
     }
 
 	public static GroupSymbol addScalarGroup(String name, TempMetadataStore metadata, GroupContext externalGroups, List symbols) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -51,8 +51,8 @@
 import com.metamatrix.query.resolver.command.UpdateResolver;
 import com.metamatrix.query.resolver.command.XMLQueryResolver;
 import com.metamatrix.query.resolver.command.XQueryResolver;
+import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Criteria;
 import com.metamatrix.query.sql.lang.From;
@@ -242,7 +242,7 @@
         
         GroupSymbol symbol = ((UnaryFromClause)clause).getGroup();
         
-        ResolverVisitorUtil.resolveGroup(symbol, metadata);
+        ResolverUtil.resolveGroup(symbol, metadata);
                 
         if (symbol.isProcedure()) {
             return false;

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -38,7 +38,6 @@
 import com.metamatrix.query.resolver.CommandResolver;
 import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.sql.ProcedureReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.DynamicCommand;
@@ -96,7 +95,7 @@
         GroupSymbol intoSymbol = dynamicCmd.getIntoGroup();
         if (intoSymbol != null) {
             if (!intoSymbol.isImplicitTempGroupSymbol()) {
-                ResolverVisitorUtil.resolveGroup(intoSymbol, metadata);
+                ResolverUtil.resolveGroup(intoSymbol, metadata);
             } else {
                 List symbols = dynamicCmd.getAsColumns();
                 ResolverUtil.resolveImplicitTempGroup(metadata, intoSymbol, symbols);

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -56,7 +56,6 @@
 import com.metamatrix.query.resolver.util.BindVariableVisitor;
 import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.ExistsCriteria;
@@ -390,7 +389,7 @@
         
         public void visit(GroupSymbol obj) {
             try {
-                ResolverVisitorUtil.resolveGroup(obj, metadata);
+                ResolverUtil.resolveGroup(obj, metadata);
             } catch (QueryResolverException err) {
                 throw new MetaMatrixRuntimeException(err);
             } catch (MetaMatrixComponentException err) {

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -36,7 +36,6 @@
 import com.metamatrix.query.resolver.CommandResolver;
 import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Create;
 import com.metamatrix.query.sql.lang.Drop;
@@ -79,12 +78,12 @@
             //exception at runtime if the user has not dropped the previous table yet
             ResolverUtil.addTempTable(metadata, group, create.getColumns());
             
-            ResolverVisitorUtil.resolveGroup(((Create)command).getTable(), metadata);
+            ResolverUtil.resolveGroup(((Create)command).getTable(), metadata);
             Set groups = new HashSet();
             groups.add(((Create)command).getTable());
             ResolverVisitor.resolveLanguageObject(command, groups, metadata);
         } else if(command.getType() == Command.TYPE_DROP) {
-            ResolverVisitorUtil.resolveGroup(((Drop)command).getTable(), metadata);
+            ResolverUtil.resolveGroup(((Drop)command).getTable(), metadata);
         }
     }
 

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-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -51,7 +51,6 @@
 import com.metamatrix.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
 import com.metamatrix.query.resolver.util.ResolverUtil;
 import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
 import com.metamatrix.query.sql.ProcedureReservedWords;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Criteria;
@@ -93,7 +92,7 @@
 	        	if(!groupName.equalsIgnoreCase(ProcedureReservedWords.INPUT) &&
 		        	 !groupName.equalsIgnoreCase(ProcedureReservedWords.CHANGING) ) {
 		        	 // set the groupSymbol on the procedure
-		        	 ResolverVisitorUtil.resolveGroup(groupSymbol, metadata);
+		        	 ResolverUtil.resolveGroup(groupSymbol, metadata);
 	        		 procCommand.setVirtualGroup(groupSymbol);
 		        	 virtualGroup = groupSymbol;
                      break;

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -42,7 +42,6 @@
 import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
 import com.metamatrix.query.sql.symbol.ElementSymbol;
 import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
 import com.metamatrix.query.sql.symbol.GroupSymbol;
 import com.metamatrix.query.sql.symbol.Reference;
 import com.metamatrix.query.util.ErrorMessageKeys;
@@ -155,7 +154,7 @@
         ElementSymbol element = (ElementSymbol) expr;
 
         GroupSymbol groupSymbol = new GroupSymbol(metadata.getGroupName(element.getName()));
-        ResolverVisitorUtil.resolveGroup(groupSymbol, metadata);
+        ResolverUtil.resolveGroup(groupSymbol, metadata);
 
         ResolverVisitor.resolveLanguageObject(element, Arrays.asList(groupSymbol), metadata);
 

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-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -23,6 +23,7 @@
 package com.metamatrix.query.resolver.util;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -34,6 +35,7 @@
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.types.TransformationException;
 import com.metamatrix.common.types.DataTypeManager.DefaultDataTypes;
@@ -44,6 +46,7 @@
 import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.metadata.GroupInfo;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
 import com.metamatrix.query.metadata.SupportConstants;
 import com.metamatrix.query.metadata.TempMetadataAdapter;
 import com.metamatrix.query.metadata.TempMetadataID;
@@ -51,6 +54,7 @@
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.lang.Limit;
 import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
 import com.metamatrix.query.sql.symbol.AbstractCaseExpression;
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
 import com.metamatrix.query.sql.symbol.AliasSymbol;
@@ -71,7 +75,32 @@
  */
 public class ResolverUtil {
 
-    // Can't construct
+    public static class ResolvedLookup {
+		private GroupSymbol group;
+		private ElementSymbol keyElement;
+		private ElementSymbol returnElement;
+		
+		void setGroup(GroupSymbol group) {
+			this.group = group;
+		}
+		public GroupSymbol getGroup() {
+			return group;
+		}
+		void setKeyElement(ElementSymbol keyElement) {
+			this.keyElement = keyElement;
+		}
+		public ElementSymbol getKeyElement() {
+			return keyElement;
+		}
+		void setReturnElement(ElementSymbol returnElement) {
+			this.returnElement = returnElement;
+		}
+		public ElementSymbol getReturnElement() {
+			return returnElement;
+		}
+	}
+
+	// Can't construct
     private ResolverUtil() {}
 
     /*
@@ -106,11 +135,11 @@
         // A type can be implicitly converted to itself, so we put the implicit
         // conversions as well as the original type in the working list of
         // conversions.
-        HashSet commonConversions = new LinkedHashSet();
+        HashSet<String> commonConversions = new LinkedHashSet<String>();
         commonConversions.add(typeNames[0]);
         commonConversions.addAll(DataTypeManager.getImplicitConversions(typeNames[0]));
         for (int i = 1; i < typeNames.length; i++ ) {
-            HashSet conversions = new LinkedHashSet(DataTypeManager.getImplicitConversions(typeNames[i]));
+            HashSet<String> conversions = new LinkedHashSet<String>(DataTypeManager.getImplicitConversions(typeNames[i]));
             conversions.add(typeNames[i]);
             // Equivalent to set intersection
             commonConversions.retainAll(conversions);
@@ -126,7 +155,7 @@
     	commonConversions.remove(DefaultDataTypes.STRING);
         commonConversions.remove(DefaultDataTypes.OBJECT);
         if (!commonConversions.isEmpty()) {
-            return (String)commonConversions.iterator().next(); 
+            return commonConversions.iterator().next(); 
         }
         return null;
     }
@@ -570,7 +599,7 @@
             if (metadata.getMetadataStore().getTempElementElementIDs(symbol.getCanonicalName())==null) {
                 addTempGroup(metadata, symbol, symbols, true);
             }
-            ResolverVisitorUtil.resolveGroup(symbol, metadata);
+            ResolverUtil.resolveGroup(symbol, metadata);
         }
     }
 
@@ -748,5 +777,202 @@
         }
         return false;
     }
+
+	/**
+	 * Check the type of the (left) expression and the type of the single
+	 * projected symbol of the subquery.  If they are not the same, try to find
+	 * an implicit conversion from the former type to the latter type, and wrap
+	 * the left expression in that conversion function; otherwise throw an
+	 * Exception.
+	 * @param expression the Expression on one side of the predicate criteria
+	 * @param crit the SubqueryContainer containing the subquery Command of the other
+	 * side of the predicate criteria
+	 * @return implicit conversion Function, or null if none is necessary
+	 * @throws QueryResolverException if a conversion is necessary but none can
+	 * be found
+	 */
+	static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit)
+		throws QueryResolverException {
+	
+		// Check that type of the expression is same as the type of the
+		// single projected symbol of the subquery
+		Class exprType = expression.getType();
+		if(exprType == null) {
+	        throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0030, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0030, expression));
+		}
+		String exprTypeName = DataTypeManager.getDataTypeName(exprType);
+	
+		Collection projectedSymbols = crit.getCommand().getProjectedSymbols();
+		if (projectedSymbols.size() != 1){
+	        throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0032, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0032, crit.getCommand()));
+		}
+		Class subqueryType = ((Expression)projectedSymbols.iterator().next()).getType();
+		String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
+		Expression result = null;
+	    try {
+	        result = convertExpression(expression, exprTypeName, subqueryTypeName);
+	    } catch (QueryResolverException qre) {
+	        throw new QueryResolverException(qre, ErrorMessageKeys.RESOLVER_0033, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0033, crit));
+	    }
+	    return result;
+	}
+
+	public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException {
+		Expression[] args = lookup.getArgs();
+		ResolvedLookup result = new ResolvedLookup();
+	    // Special code to handle setting return type of the lookup function to match the type of the return element
+	    if( args[0] instanceof Constant && args[1] instanceof Constant && args[2] instanceof Constant) {
+	        // If code table name in lookup function refers to virtual group, throws exception
+			GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
+			try {
+				groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
+				if (groupSym.getMetadataID() instanceof TempMetadataID) {
+					throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0065, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0065, ((Constant)args[0]).getValue()));
+				}
+			} catch(QueryMetadataException e) {
+				throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, ((Constant)args[0]).getValue()));
+			}
+			result.setGroup(groupSym);
+			
+			List<GroupSymbol> groups = Arrays.asList(groupSym);
+			
+			String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
+			ElementSymbol returnElement = new ElementSymbol(returnElementName);
+	        try {
+	            ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
+	        } catch(QueryMetadataException e) {
+	            throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, returnElementName));
+	        }
+			result.setReturnElement(returnElement);
+	        
+	        String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
+	        ElementSymbol keyElement = new ElementSymbol(keyElementName);
+	        try {
+	            ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
+	        } catch(QueryMetadataException e) {
+	            throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
+	        }
+			result.setKeyElement(keyElement);
+			return result;
+	    } 
+	    throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0063, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0063));
+	}
+
+	private static QueryResolverException handleUnresolvedGroup(GroupSymbol symbol, String description) {
+		UnresolvedSymbolDescription usd = new UnresolvedSymbolDescription(symbol.toString(), description);
+	    QueryResolverException e = new QueryResolverException(usd.getDescription()+": "+usd.getSymbol()); //$NON-NLS-1$
+	    e.setUnresolvedSymbols(Arrays.asList(usd));
+	    return e;
+	}
+
+	public static void resolveGroup(GroupSymbol symbol, QueryMetadataInterface metadata)
+	    throws MetaMatrixComponentException, QueryResolverException {
+	
+	    if (symbol.getMetadataID() != null){
+	        return;
+	    }
+	
+	    // determine the "metadataID" part of the symbol to look up
+	    String potentialID = symbol.getNonCorrelationName();
+	    
+	    String name = symbol.getName();
+	    String definition = symbol.getDefinition();
+	
+	    Object groupID = null;
+	    try {
+	        // get valid GroupID for possibleID - this may throw exceptions if group is invalid
+	        groupID = metadata.getGroupID(potentialID);
+	    } catch(QueryMetadataException e) {
+	        // didn't find this group ID
+	    } 
+	
+	    // If that didn't work, try to strip a vdb name from potentialID
+	    String vdbName = null;
+	    if(groupID == null) {
+			String newPotentialID = potentialID;
+	        int vdbIndex = potentialID.indexOf(ElementSymbol.SEPARATOR);
+	        if(vdbIndex >= 0) {
+	            String potentialVdbName = potentialID.substring(0, vdbIndex);
+	            newPotentialID = potentialID.substring(vdbIndex+1);
+	
+	            try {
+	                groupID = metadata.getGroupID(newPotentialID);
+	                vdbName = potentialVdbName;
+	            } catch(QueryMetadataException e) {
+	                // ignore - just didn't find it
+	            } 
+	            if(groupID != null) {
+	            	potentialID = newPotentialID;
+	            }
+	        }
+	    }
+	
+	    // the group could be partially qualified,  verify that this group exists
+	    // and there is only one group that matches the given partial name
+	    if(groupID == null) {
+	    	Collection groupNames = null;
+	    	try {
+	        	groupNames = metadata.getGroupsForPartialName(potentialID);
+	        } catch(QueryMetadataException e) {
+	            // ignore - just didn't find it
+	        } 
+	
+	        if(groupNames != null) {
+	            int matches = groupNames.size();
+	            if(matches == 1) {
+	            	potentialID = (String) groupNames.iterator().next();
+			        try {
+			            // get valid GroupID for possibleID - this may throw exceptions if group is invalid
+			            groupID = metadata.getGroupID(potentialID);
+			            //set group full name
+			            if(symbol.getDefinition() != null){
+			            	symbol.setDefinition(potentialID);
+			            }else{
+			            	symbol.setName(potentialID);
+			            }
+			        } catch(QueryMetadataException e) {
+			            // didn't find this group ID
+			        } 
+	            } else if(matches > 1) {
+	                throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0055));
+	            }
+	        }
+	    }
+	    
+	    if (groupID == null || metadata.isProcedure(groupID)) {
+		    //try procedure relational resolving
+	        try {
+	            StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(potentialID);
+	            symbol.setProcedure(true);
+	            groupID = storedProcedureInfo.getProcedureID();
+	        } catch(QueryMetadataException e) {
+	            // just ignore
+	        } 
+	    }
+	    
+	    if(groupID == null) {
+	        throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0056));
+	    }
+	    // set real metadata ID in the symbol
+	    symbol.setMetadataID(groupID);
+	    if(vdbName != null) {
+	        // reset name or definition to strip vdb name
+	        if(symbol.getDefinition() == null) {
+	            symbol.setName(potentialID);
+	        } else {
+	            symbol.setDefinition(potentialID);
+	        }
+	    }
+	    try {
+	        if (!symbol.isProcedure()) {
+	            symbol.setIsTempTable(metadata.isTemporaryTable(groupID));
+	        }
+	    } catch(QueryMetadataException e) {
+	        // should not come here
+	    } 
+	    
+	    symbol.setOutputDefinition(definition);
+	    symbol.setOutputName(name);
+	}
     
 }

Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -288,7 +288,7 @@
 
     public void visit(SubqueryCompareCriteria obj) {
         try {
-            obj.setLeftExpression(ResolverVisitorUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj));
+            obj.setLeftExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getLeftExpression(), obj));
         } catch(QueryResolverException e) {
             handleException(e);
         }
@@ -297,7 +297,7 @@
 
     public void visit(SubquerySetCriteria obj) {
         try {
-            obj.setExpression(ResolverVisitorUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj));
+            obj.setExpression(ResolverUtil.resolveSubqueryPredicateCriteria(obj.getExpression(), obj));
         } catch(QueryResolverException e) {
             handleException(e);
         }
@@ -457,7 +457,7 @@
 	            throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0037, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0037, new Object[] {DataTypeManager.getDataTypeName(srcTypeClass), dataType}));
 	        }
 	    } else if(fd.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
-			ResolverVisitorUtil.ResolvedLookup lookup = ResolverVisitorUtil.resolveLookup(function, metadata);
+			ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(function, metadata);
 			fd = library.copyFunctionChangeReturnType(fd, lookup.getReturnElement().getType());
 	    } else if(fd.getName().equalsIgnoreCase(FunctionLibrary.XPATHVALUE)) {
 	        // Validate the xpath value is valid

Deleted: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitorUtil.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -1,271 +0,0 @@
-/*
- * 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.resolver.util;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-public class ResolverVisitorUtil {
-	
-	public static class ResolvedLookup {
-		private GroupSymbol group;
-		private ElementSymbol keyElement;
-		private ElementSymbol returnElement;
-		
-		void setGroup(GroupSymbol group) {
-			this.group = group;
-		}
-		public GroupSymbol getGroup() {
-			return group;
-		}
-		void setKeyElement(ElementSymbol keyElement) {
-			this.keyElement = keyElement;
-		}
-		public ElementSymbol getKeyElement() {
-			return keyElement;
-		}
-		void setReturnElement(ElementSymbol returnElement) {
-			this.returnElement = returnElement;
-		}
-		public ElementSymbol getReturnElement() {
-			return returnElement;
-		}
-	}
-	
-    /**
-     * Check the type of the (left) expression and the type of the single
-     * projected symbol of the subquery.  If they are not the same, try to find
-     * an implicit conversion from the former type to the latter type, and wrap
-     * the left expression in that conversion function; otherwise throw an
-     * Exception.
-     * @param expression the Expression on one side of the predicate criteria
-     * @param crit the SubqueryContainer containing the subquery Command of the other
-     * side of the predicate criteria
-     * @return implicit conversion Function, or null if none is necessary
-     * @throws QueryResolverException if a conversion is necessary but none can
-     * be found
-     */
-    static Expression resolveSubqueryPredicateCriteria(Expression expression, SubqueryContainer crit)
-    	throws QueryResolverException {
-    
-    	// Check that type of the expression is same as the type of the
-    	// single projected symbol of the subquery
-    	Class exprType = expression.getType();
-    	if(exprType == null) {
-            throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0030, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0030, expression));
-    	}
-    	String exprTypeName = DataTypeManager.getDataTypeName(exprType);
-    
-    	Collection projectedSymbols = crit.getCommand().getProjectedSymbols();
-    	if (projectedSymbols.size() != 1){
-            throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0032, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0032, crit.getCommand()));
-    	}
-    	Class subqueryType = ((Expression)projectedSymbols.iterator().next()).getType();
-    	String subqueryTypeName = DataTypeManager.getDataTypeName(subqueryType);
-    	Expression result = null;
-        try {
-            result = ResolverUtil.convertExpression(expression, exprTypeName, subqueryTypeName);
-        } catch (QueryResolverException qre) {
-            throw new QueryResolverException(qre, ErrorMessageKeys.RESOLVER_0033, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0033, crit));
-        }
-        return result;
-    }
-
-    public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException {
-    	Expression[] args = lookup.getArgs();
-    	ResolvedLookup result = new ResolvedLookup();
-        // Special code to handle setting return type of the lookup function to match the type of the return element
-        if( args[0] instanceof Constant && args[1] instanceof Constant && args[2] instanceof Constant) {
-            // If code table name in lookup function refers to virtual group, throws exception
-			GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
-			try {
-				groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
-				if (groupSym.getMetadataID() instanceof TempMetadataID) {
-					throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0065, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0065, ((Constant)args[0]).getValue()));
-				}
-			} catch(QueryMetadataException e) {
-				throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, ((Constant)args[0]).getValue()));
-			}
-			result.setGroup(groupSym);
-			
-			List<GroupSymbol> groups = Arrays.asList(groupSym);
-			
-			String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
-			ElementSymbol returnElement = new ElementSymbol(returnElementName);
-            try {
-                ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
-            } catch(QueryMetadataException e) {
-                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, returnElementName));
-            }
-			result.setReturnElement(returnElement);
-            
-            String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
-            ElementSymbol keyElement = new ElementSymbol(keyElementName);
-            try {
-                ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
-            } catch(QueryMetadataException e) {
-                throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
-            }
-			result.setKeyElement(keyElement);
-			return result;
-        } 
-        throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0063, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0063));
-    }
-
-    private static QueryResolverException handleUnresolvedGroup(GroupSymbol symbol, String description) {
-		UnresolvedSymbolDescription usd = new UnresolvedSymbolDescription(symbol.toString(), description);
-	    QueryResolverException e = new QueryResolverException(usd.getDescription()+": "+usd.getSymbol()); //$NON-NLS-1$
-	    e.setUnresolvedSymbols(Arrays.asList(usd));
-	    return e;
-	}
-
-	public static void resolveGroup(GroupSymbol symbol, QueryMetadataInterface metadata)
-	    throws MetaMatrixComponentException, QueryResolverException {
-	
-	    if (symbol.getMetadataID() != null){
-	        return;
-	    }
-	
-	    // determine the "metadataID" part of the symbol to look up
-	    String potentialID = symbol.getNonCorrelationName();
-	    
-	    String name = symbol.getName();
-	    String definition = symbol.getDefinition();
-	
-	    Object groupID = null;
-	    try {
-	        // get valid GroupID for possibleID - this may throw exceptions if group is invalid
-	        groupID = metadata.getGroupID(potentialID);
-	    } catch(QueryMetadataException e) {
-	        // didn't find this group ID
-	    } 
-	
-	    // If that didn't work, try to strip a vdb name from potentialID
-	    String vdbName = null;
-	    if(groupID == null) {
-			String newPotentialID = potentialID;
-	        int vdbIndex = potentialID.indexOf(ElementSymbol.SEPARATOR);
-	        if(vdbIndex >= 0) {
-	            String potentialVdbName = potentialID.substring(0, vdbIndex);
-	            newPotentialID = potentialID.substring(vdbIndex+1);
-	
-	            try {
-	                groupID = metadata.getGroupID(newPotentialID);
-	                vdbName = potentialVdbName;
-	            } catch(QueryMetadataException e) {
-	                // ignore - just didn't find it
-	            } 
-	            if(groupID != null) {
-	            	potentialID = newPotentialID;
-	            }
-	        }
-	    }
-	
-	    // the group could be partially qualified,  verify that this group exists
-	    // and there is only one group that matches the given partial name
-	    if(groupID == null) {
-	    	Collection groupNames = null;
-	    	try {
-	        	groupNames = metadata.getGroupsForPartialName(potentialID);
-	        } catch(QueryMetadataException e) {
-	            // ignore - just didn't find it
-	        } 
-	
-	        if(groupNames != null) {
-	            int matches = groupNames.size();
-	            if(matches == 1) {
-	            	potentialID = (String) groupNames.iterator().next();
-			        try {
-			            // get valid GroupID for possibleID - this may throw exceptions if group is invalid
-			            groupID = metadata.getGroupID(potentialID);
-			            //set group full name
-			            if(symbol.getDefinition() != null){
-			            	symbol.setDefinition(potentialID);
-			            }else{
-			            	symbol.setName(potentialID);
-			            }
-			        } catch(QueryMetadataException e) {
-			            // didn't find this group ID
-			        } 
-	            } else if(matches > 1) {
-	                throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0055));
-	            }
-	        }
-	    }
-	    
-	    if (groupID == null || metadata.isProcedure(groupID)) {
-		    //try procedure relational resolving
-	        try {
-	            StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(potentialID);
-	            symbol.setProcedure(true);
-	            groupID = storedProcedureInfo.getProcedureID();
-	        } catch(QueryMetadataException e) {
-	            // just ignore
-	        } 
-	    }
-	    
-	    if(groupID == null) {
-	        throw handleUnresolvedGroup(symbol, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0056));
-	    }
-	    // set real metadata ID in the symbol
-	    symbol.setMetadataID(groupID);
-	    if(vdbName != null) {
-	        // reset name or definition to strip vdb name
-	        if(symbol.getDefinition() == null) {
-	            symbol.setName(potentialID);
-	        } else {
-	            symbol.setDefinition(potentialID);
-	        }
-	    }
-	    try {
-	        if (!symbol.isProcedure()) {
-	            symbol.setIsTempTable(metadata.isTemporaryTable(groupID));
-	        }
-	    } catch(QueryMetadataException e) {
-	        // should not come here
-	    } 
-	    
-	    symbol.setOutputDefinition(definition);
-	    symbol.setOutputName(name);
-	}
-
-}

Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -41,8 +41,7 @@
 import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.metadata.SupportConstants;
 import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil.ResolvedLookup;
+import com.metamatrix.query.resolver.util.ResolverUtil.ResolvedLookup;
 import com.metamatrix.query.sql.LanguageObject;
 import com.metamatrix.query.sql.LanguageVisitor;
 import com.metamatrix.query.sql.ProcedureReservedWords;
@@ -282,7 +281,7 @@
     public void visit(Function obj) {
     	if(FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
     		try {
-				ResolvedLookup resolvedLookup = ResolverVisitorUtil.resolveLookup(obj, getMetadata());
+				ResolverUtil.ResolvedLookup resolvedLookup = ResolverUtil.resolveLookup(obj, getMetadata());
 				if(ValidationVisitor.isNonComparable(resolvedLookup.getKeyElement())) {
 		            handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_lookup_key", resolvedLookup.getKeyElement()), resolvedLookup.getKeyElement()); //$NON-NLS-1$            
 		        }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -100,6 +100,7 @@
         tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
         tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
         tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
+        tgtCaps.setCapabilitySupport(Capability.QUERY_GROUP_BY, srcCaps.supportsGroupBy());
 
         List functions = srcCaps.getSupportedFunctions();
         if(functions != null && functions.size() > 0) {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -42,8 +42,7 @@
 import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.metadata.TempMetadataID;
 import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil.ResolvedLookup;
+import com.metamatrix.query.resolver.util.ResolverUtil.ResolvedLookup;
 import com.metamatrix.query.sql.lang.Delete;
 import com.metamatrix.query.sql.lang.Insert;
 import com.metamatrix.query.sql.lang.Into;
@@ -115,7 +114,7 @@
     	if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
     		try {
     			List<Symbol> symbols = new LinkedList<Symbol>();
-				ResolvedLookup lookup = ResolverVisitorUtil.resolveLookup(obj, this.getMetadata());
+				ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(obj, this.getMetadata());
 				symbols.add(lookup.getGroup());
 				symbols.add(lookup.getKeyElement());
 				symbols.add(lookup.getReturnElement());

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -33,8 +33,8 @@
 import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.query.function.FunctionLibrary;
 import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitorUtil.ResolvedLookup;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.resolver.util.ResolverUtil.ResolvedLookup;
 import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.sql.lang.Delete;
 import com.metamatrix.query.sql.lang.Insert;
@@ -90,7 +90,7 @@
     public void visit(Function obj) {
     	if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
 			try {
-	    		ResolvedLookup resolvedLookup = ResolverVisitorUtil.resolveLookup(obj, getMetadata());
+	    		ResolverUtil.ResolvedLookup resolvedLookup = ResolverUtil.resolveLookup(obj, getMetadata());
 	    		validateModelVisibility(getMetadata().getModelID(resolvedLookup.getGroup().getMetadataID()), resolvedLookup.getGroup());
 			} catch (QueryResolverException e) {
 				handleException(e, obj);

Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java	2009-04-22 20:03:21 UTC (rev 828)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java	2009-04-23 15:33:20 UTC (rev 829)
@@ -431,4 +431,23 @@
         }); 
     }               
     
+    public void testNoGroupAggregatePushdown() {
+        FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+        BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+        caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+        caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+        caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+        capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+        FakeMetadataFacade metadata = FakeMetadataFactory.exampleBQTCached();
+        
+        ProcessorPlan plan = TestOptimizer.helpPlan(
+              "select count(*) from bqt1.smalla",  //$NON-NLS-1$
+              metadata, null, capFinder,
+              new String[] { 
+                "SELECT count(*) from bqt1.smalla"},  //$NON-NLS-1$
+                true); 
+                  
+        TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);                                    
+    }
+    
 }




More information about the teiid-commits mailing list