[teiid-commits] teiid SVN: r3915 - in trunk: api/src/main/java/org/teiid/language and 20 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Mar 6 05:59:02 EST 2012


Author: shawkins
Date: 2012-03-06 05:58:59 -0500 (Tue, 06 Mar 2012)
New Revision: 3915

Added:
   trunk/api/src/main/java/org/teiid/UserDefinedAggregate.java
   trunk/api/src/main/java/org/teiid/metadata/AggregateAttributes.java
Modified:
   trunk/api/src/main/java/org/teiid/language/AggregateFunction.java
   trunk/api/src/main/java/org/teiid/language/LanguageFactory.java
   trunk/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java
   trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
   trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
   trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
   trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
   trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
   trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
   trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
   trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java
   trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
   trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
   trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
   trunk/engine/src/main/resources/org/teiid/query/i18n.properties
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java
   trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java
   trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
   trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
   trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java
   trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java
   trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
Log:
TEIID-1560 adding a user defined aggregate function implementation class, a metadata holder for user defined aggregates, and some cleanup of aggregate logic

Added: trunk/api/src/main/java/org/teiid/UserDefinedAggregate.java
===================================================================
--- trunk/api/src/main/java/org/teiid/UserDefinedAggregate.java	                        (rev 0)
+++ trunk/api/src/main/java/org/teiid/UserDefinedAggregate.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -0,0 +1,34 @@
+/*
+ * 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 org.teiid;
+
+/**
+ * Interface to be implemented by a user defined aggregate function.
+ * @param <T>
+ */
+public interface UserDefinedAggregate<T> {
+	
+	void init(CommandContext commandContext);
+	T getResult();
+
+}


Property changes on: trunk/api/src/main/java/org/teiid/UserDefinedAggregate.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/api/src/main/java/org/teiid/language/AggregateFunction.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/AggregateFunction.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/api/src/main/java/org/teiid/language/AggregateFunction.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -22,12 +22,14 @@
 
 package org.teiid.language;
 
+import java.util.List;
+
 import org.teiid.language.visitor.LanguageObjectVisitor;
 
 /**
  * Represents an aggregate function.
  */
-public class AggregateFunction extends BaseLanguageObject implements Expression {
+public class AggregateFunction extends Function {
     
     public static final String COUNT = "COUNT"; //$NON-NLS-1$
     public static final String AVG = "AVG"; //$NON-NLS-1$
@@ -39,17 +41,14 @@
 	public static final String VAR_SAMP = "VAR_SAMP"; //$NON-NLS-1$
 	public static final String VAR_POP = "VAR_POP"; //$NON-NLS-1$
 	
-    private Expression expression;
     private String aggName;
     private boolean isDistinct;
-    private Class<?> type;
     private Expression condition;
     
-    public AggregateFunction(String aggName, boolean isDistinct, Expression exp, Class<?> type) {
-        this.expression = exp;
+    public AggregateFunction(String aggName, boolean isDistinct, List<? extends Expression> params, Class<?> type) {
+    	super(aggName, params, type);
         this.aggName = aggName;
         this.isDistinct = isDistinct;
-        this.type = type;
     }
 
     /** 
@@ -74,10 +73,15 @@
      * Get the expression within the aggregate function.  The expression will be 
      * null for the special case COUNT(*).  This is the only case where the 
      * expression will be null
+     * Only valid for 0/1 ary aggregates
      * @return The expression or null for COUNT(*)
+     * @deprecated
      */
     public Expression getExpression() {
-        return this.expression;
+    	if (this.getParameters().isEmpty()) {
+    		return null;
+    	}
+        return this.getParameters().get(0);
     }
     
     public void acceptVisitor(LanguageObjectVisitor visitor) {
@@ -104,23 +108,6 @@
     }
 
     /**
-     * Set the expression within the aggregate function.  The expression will be
-     * null for the special case COUNT(*). 
-     * @param expression The new expression
-     */
-    public void setExpression(Expression expression) {
-        this.expression = expression;
-    }
-
-    public Class<?> getType() {
-        return this.type;
-    }
-
-    public void setType(Class<?> type) {
-        this.type = type;
-    }
-    
-    /**
      * 
      * @return the filter clause condition
      */

Modified: trunk/api/src/main/java/org/teiid/language/LanguageFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/LanguageFactory.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/api/src/main/java/org/teiid/language/LanguageFactory.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -22,6 +22,7 @@
 
 package org.teiid.language;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -44,7 +45,7 @@
     public static final LanguageFactory INSTANCE = new LanguageFactory();
 
     public AggregateFunction createAggregate(String name, boolean isDistinct, Expression expression, Class<?> type) {
-        return new AggregateFunction(name, isDistinct, expression, type);
+        return new AggregateFunction(name, isDistinct, new ArrayList<Expression>(Arrays.asList(expression)), type);
     }
 
     public Comparison createCompareCriteria(

Modified: trunk/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -22,39 +22,7 @@
 
 package org.teiid.language.visitor;
 
-import org.teiid.language.AggregateFunction;
-import org.teiid.language.AndOr;
-import org.teiid.language.BatchedUpdates;
-import org.teiid.language.Call;
-import org.teiid.language.Comparison;
-import org.teiid.language.Delete;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.DerivedTable;
-import org.teiid.language.Exists;
-import org.teiid.language.ExpressionValueSource;
-import org.teiid.language.Function;
-import org.teiid.language.GroupBy;
-import org.teiid.language.In;
-import org.teiid.language.Insert;
-import org.teiid.language.IsNull;
-import org.teiid.language.Join;
-import org.teiid.language.Like;
-import org.teiid.language.Not;
-import org.teiid.language.OrderBy;
-import org.teiid.language.QueryExpression;
-import org.teiid.language.ScalarSubquery;
-import org.teiid.language.SearchedCase;
-import org.teiid.language.SearchedWhenClause;
-import org.teiid.language.Select;
-import org.teiid.language.SetClause;
-import org.teiid.language.SetQuery;
-import org.teiid.language.SubqueryComparison;
-import org.teiid.language.SubqueryIn;
-import org.teiid.language.Update;
-import org.teiid.language.WindowFunction;
-import org.teiid.language.WindowSpecification;
-import org.teiid.language.With;
-import org.teiid.language.WithItem;
+import org.teiid.language.*;
 
 /**
  * Visits each node in  a hierarchy of LanguageObjects. The default
@@ -80,7 +48,7 @@
     }
     
     public void visit(AggregateFunction obj) {
-        visitNode(obj.getExpression());
+        visitNodes(obj.getParameters());
         visitNode(obj.getCondition());
     }
     

Modified: trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -134,12 +134,10 @@
                   .append(Tokens.SPACE);
         }
         
-        if (obj.getExpression() == null) {
-        	if (SQLConstants.NonReserved.COUNT.equalsIgnoreCase(obj.getName())) {
-        		buffer.append(Tokens.ALL_COLS);
-        	}
+        if (obj.getParameters().isEmpty() && SQLConstants.NonReserved.COUNT.equalsIgnoreCase(obj.getName())) {
+    		buffer.append(Tokens.ALL_COLS);
         } else {
-            append(obj.getExpression());
+        	append(obj.getParameters());
         }
         buffer.append(Tokens.RPAREN);
         if (obj.getCondition() != null) {

Added: trunk/api/src/main/java/org/teiid/metadata/AggregateAttributes.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/AggregateAttributes.java	                        (rev 0)
+++ trunk/api/src/main/java/org/teiid/metadata/AggregateAttributes.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -0,0 +1,80 @@
+/*
+ * 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 org.teiid.metadata;
+
+import java.io.Serializable;
+
+/**
+ * Holds metadata related to user defined aggregate functions.
+ */
+public class AggregateAttributes implements Serializable {
+	
+	private static final long serialVersionUID = 5398000844375944790L;
+
+	private boolean allowsDistinct;
+	private boolean windowable;
+	private boolean decomposable;
+	private boolean respectsNulls;
+	private boolean allowsOrderBy;
+	
+	public boolean allowsOrderBy() {
+		return allowsOrderBy;
+	}
+	
+	public void setAllowsOrderBy(boolean allowsOrderBy) {
+		this.allowsOrderBy = allowsOrderBy;
+	}
+	
+	public boolean allowsDistinct() {
+		return allowsDistinct;
+	}
+	
+	public void setAllowsDistinct(boolean allowsDistinct) {
+		this.allowsDistinct = allowsDistinct;
+	}
+	
+	public boolean isWindowable() {
+		return windowable;
+	}
+	
+	public void setWindowable(boolean windowable) {
+		this.windowable = windowable;
+	}
+	
+	public boolean isDecomposable() {
+		return decomposable;
+	}
+	
+	public void setDecomposable(boolean decomposable) {
+		this.decomposable = decomposable;
+	}
+	
+	public boolean respectsNulls() {
+		return respectsNulls;
+	}
+	
+	public void setRespectsNulls(boolean respectsNulls) {
+		this.respectsNulls = respectsNulls;
+	}
+	
+}


Property changes on: trunk/api/src/main/java/org/teiid/metadata/AggregateAttributes.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -104,6 +104,7 @@
     private String invocationClass;
     private String invocationMethod;
     private boolean nullOnNull;
+    private AggregateAttributes aggregateAttributes;
     
     private Determinism determinism = Determinism.DETERMINISTIC;
     
@@ -479,4 +480,12 @@
     public void setClassloader(ClassLoader classloader) {
     	this.classLoader = classloader;
     }
+    
+    public AggregateAttributes getAggregateAttributes() {
+		return aggregateAttributes;
+	}
+    
+    public void setAggregateAttributes(AggregateAttributes aggregateAttributes) {
+		this.aggregateAttributes = aggregateAttributes;
+	}
 }

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -227,7 +227,7 @@
     public List<?> translate(LanguageObject obj, ExecutionContext context) {
     	if (obj instanceof AggregateFunction) {
     		AggregateFunction agg = (AggregateFunction)obj;
-    		if (agg.getExpression() != null && TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(agg.getExpression().getType())) {
+    		if (agg.getParameters().size() == 1 && TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(agg.getParameters().get(0).getType())) {
             	if (agg.getName().equalsIgnoreCase(NonReserved.MIN)) {
             		agg.setName("bool_and"); //$NON-NLS-1$
             	} else if (agg.getName().equalsIgnoreCase(NonReserved.MAX)) {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -22,16 +22,7 @@
 
 package org.teiid.dqp.internal.datamgr;
 
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.RandomAccess;
+import java.util.*;
 
 import org.teiid.api.exception.query.QueryMetadataException;
 import org.teiid.client.metadata.ParameterInfo;
@@ -41,92 +32,33 @@
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.core.TeiidRuntimeException;
-import org.teiid.language.AggregateFunction;
-import org.teiid.language.AndOr;
-import org.teiid.language.Argument;
-import org.teiid.language.Argument.Direction;
-import org.teiid.language.BatchedCommand;
-import org.teiid.language.BatchedUpdates;
-import org.teiid.language.Call;
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Comparison;
-import org.teiid.language.Comparison.Operator;
-import org.teiid.language.Condition;
+import org.teiid.language.*;
 import org.teiid.language.DerivedColumn;
-import org.teiid.language.DerivedTable;
-import org.teiid.language.Exists;
-import org.teiid.language.ExpressionValueSource;
-import org.teiid.language.In;
-import org.teiid.language.InsertValueSource;
-import org.teiid.language.IsNull;
-import org.teiid.language.Join;
-import org.teiid.language.Like;
-import org.teiid.language.Literal;
-import org.teiid.language.NamedTable;
-import org.teiid.language.Not;
-import org.teiid.language.Parameter;
-import org.teiid.language.QueryExpression;
-import org.teiid.language.SearchedCase;
-import org.teiid.language.SearchedWhenClause;
 import org.teiid.language.Select;
-import org.teiid.language.SortSpecification;
+import org.teiid.language.WindowSpecification;
+import org.teiid.language.Argument.Direction;
+import org.teiid.language.Comparison.Operator;
 import org.teiid.language.SortSpecification.Ordering;
-import org.teiid.language.SubqueryComparison;
 import org.teiid.language.SubqueryComparison.Quantifier;
-import org.teiid.language.SubqueryIn;
-import org.teiid.language.TableReference;
-import org.teiid.language.WindowSpecification;
-import org.teiid.language.With;
-import org.teiid.language.WithItem;
-import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.metadata.Procedure;
 import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.*;
 import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Criteria;
 import org.teiid.query.sql.lang.Delete;
-import org.teiid.query.sql.lang.DependentSetCriteria;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.FromClause;
 import org.teiid.query.sql.lang.GroupBy;
 import org.teiid.query.sql.lang.Insert;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.JoinPredicate;
-import org.teiid.query.sql.lang.JoinType;
 import org.teiid.query.sql.lang.Limit;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.NotCriteria;
 import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.OrderByItem;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.QueryCommand;
-import org.teiid.query.sql.lang.SPParameter;
 import org.teiid.query.sql.lang.SetClause;
-import org.teiid.query.sql.lang.SetClauseList;
-import org.teiid.query.sql.lang.SetCriteria;
 import org.teiid.query.sql.lang.SetQuery;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.lang.SubqueryCompareCriteria;
-import org.teiid.query.sql.lang.SubqueryFromClause;
-import org.teiid.query.sql.lang.SubquerySetCriteria;
-import org.teiid.query.sql.lang.UnaryFromClause;
 import org.teiid.query.sql.lang.Update;
-import org.teiid.query.sql.lang.WithQueryCommand;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.AliasSymbol;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.*;
 import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.ExpressionSymbol;
 import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
 import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.Symbol;
 import org.teiid.query.sql.symbol.WindowFunction;
 import org.teiid.translator.TranslatorException;
 
@@ -687,9 +619,13 @@
     }
 
     AggregateFunction translate(AggregateSymbol symbol) {
+    	List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(symbol.getArgs().length);
+    	for (Expression expression : symbol.getArgs()) {
+			params.add(translate(expression));
+		}
     	AggregateFunction af = new AggregateFunction(symbol.getAggregateFunction().name(), 
                                 symbol.isDistinct(), 
-                                translate(symbol.getExpression()),
+                                params,
                                 symbol.getType());
     	af.setCondition(translate(symbol.getCondition()));
     	return af;

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -210,7 +210,7 @@
             	if (RelationalNodeUtil.isUpdate(accessNode.getCommand())) {
             		update = true;
             		GroupingNode groupNode = new GroupingNode(getID());                    
-            		AggregateSymbol sumCount = new AggregateSymbol("SumCount", NonReserved.SUM, false, accessNode.getElements().get(0)); //$NON-NLS-1$          		
+            		AggregateSymbol sumCount = new AggregateSymbol(NonReserved.SUM, false, accessNode.getElements().get(0)); //$NON-NLS-1$          		
             		List<Expression> outputElements = new ArrayList<Expression>(1);            		
             		outputElements.add(sumCount); 
             		groupNode.setElements(outputElements);

Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -612,6 +612,7 @@
 		TEIID30574,		
 		TEIID30580,
 		TEIID30581,
-		TEIID30590
+		TEIID30590,
+		TEIID30600, TEIID30601 //User defined aggregate errors
 	}
 }

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -34,6 +34,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.teiid.UserDefinedAggregate;
 import org.teiid.core.CoreConstants;
 import org.teiid.core.TeiidRuntimeException;
 import org.teiid.core.types.DataTypeManager;
@@ -338,8 +339,16 @@
 
         		// Check that method is static
         		if(! Modifier.isStatic(modifiers)) {
-        			 throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30392, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30392, method.getName(), invocationMethod));
+        			if (method.getAggregateAttributes() == null) {
+        				throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30392, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30392, method.getName(), invocationMethod));
+        			}
+        		} else if (method.getAggregateAttributes() != null) {
+        			throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30600, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30600, method.getName(), invocationMethod));
         		}
+        		
+        		if (method.getAggregateAttributes() != null && !(UserDefinedAggregate.class.isAssignableFrom(method.getClass()))) {
+        			throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30601, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30601, method.getName(), method.getInvocationClass(), UserDefinedAggregate.class.getName()));
+        		}
             }
         }
 

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -23,7 +23,6 @@
 package org.teiid.query.metadata;
 
 import java.io.ByteArrayInputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -47,36 +47,17 @@
 import org.teiid.query.optimizer.relational.OptimizerRule;
 import org.teiid.query.optimizer.relational.RuleStack;
 import org.teiid.query.optimizer.relational.plantree.NodeConstants;
-import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
 import org.teiid.query.optimizer.relational.plantree.NodeEditor;
 import org.teiid.query.optimizer.relational.plantree.NodeFactory;
 import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
 import org.teiid.query.processor.ProcessorPlan;
 import org.teiid.query.processor.relational.AccessNode;
 import org.teiid.query.processor.relational.RelationalPlan;
 import org.teiid.query.resolver.util.ResolverUtil;
 import org.teiid.query.rewriter.QueryRewriter;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.lang.CompoundCriteria;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.ExistsCriteria;
-import org.teiid.query.sql.lang.From;
-import org.teiid.query.sql.lang.FromClause;
-import org.teiid.query.sql.lang.GroupBy;
-import org.teiid.query.sql.lang.Insert;
-import org.teiid.query.sql.lang.JoinPredicate;
-import org.teiid.query.sql.lang.JoinType;
-import org.teiid.query.sql.lang.Limit;
-import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.OrderByItem;
-import org.teiid.query.sql.lang.Query;
-import org.teiid.query.sql.lang.QueryCommand;
-import org.teiid.query.sql.lang.Select;
-import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.*;
 import org.teiid.query.sql.lang.SetQuery.Operation;
-import org.teiid.query.sql.lang.SubqueryContainer;
-import org.teiid.query.sql.lang.SubqueryFromClause;
-import org.teiid.query.sql.lang.UnaryFromClause;
 import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
 import org.teiid.query.sql.symbol.AggregateSymbol;
 import org.teiid.query.sql.symbol.Constant;
@@ -607,10 +588,9 @@
 	        aggs.addAll(AggregateSymbolCollectorVisitor.getAggregates(having, true));
 	    }
 	    for (AggregateSymbol aggregateSymbol : aggs) {
-	        if (aggregateSymbol.getExpression() != null) {
-	            Expression expr = aggregateSymbol.getExpression();
+        	for (Expression expr : aggregateSymbol.getArgs()) {
 	            newSelectColumns.add(SymbolMap.getExpression(expr));
-	        }
+        	}
 	    }
 	    Select innerSelect = new Select();
 	    for (Expression expr : newSelectColumns) {

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -669,7 +669,7 @@
 		if (stagedGroupingSymbols.isEmpty()) {
 		    // if the source has no rows we need to insert a select node with criteria count(*)>0
 		    PlanNode selectNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
-		    AggregateSymbol count = new AggregateSymbol("stagedAgg", NonReserved.COUNT, false, null); //$NON-NLS-1$
+		    AggregateSymbol count = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
 		    aggregates.add(count); //consider the count aggregate for the push down call below
 		    selectNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, new CompareCriteria(count, CompareCriteria.GT,
 		                                                                                   new Constant(new Integer(0))));
@@ -862,7 +862,7 @@
             Type aggFunction = partitionAgg.getAggregateFunction();
             if (aggFunction == Type.COUNT) {
                 //COUNT(x) -> CONVERT(SUM(COUNT(x)), INTEGER)
-                AggregateSymbol newAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, partitionAgg); //$NON-NLS-1$
+                AggregateSymbol newAgg = new AggregateSymbol(NonReserved.SUM, false, partitionAgg); //$NON-NLS-1$
                 // Build conversion function to convert SUM (which returns LONG) back to INTEGER
                 Function convertFunc = new Function(FunctionLibrary.CONVERT, new Expression[] {newAgg, new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()))});
                 ResolverVisitor.resolveLanguageObject(convertFunc, metadata);
@@ -871,11 +871,11 @@
                 nestedAggregates.add(partitionAgg);
             } else if (aggFunction == Type.AVG) {
                 //AVG(x) -> SUM(SUM(x)) / SUM(COUNT(x))
-                AggregateSymbol countAgg = new AggregateSymbol("stagedAgg", NonReserved.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
-                AggregateSymbol sumAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
+                AggregateSymbol countAgg = new AggregateSymbol(NonReserved.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
+                AggregateSymbol sumAgg = new AggregateSymbol(NonReserved.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
                 
-                AggregateSymbol sumSumAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, sumAgg); //$NON-NLS-1$
-                AggregateSymbol sumCountAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, countAgg); //$NON-NLS-1$
+                AggregateSymbol sumSumAgg = new AggregateSymbol(NonReserved.SUM, false, sumAgg); //$NON-NLS-1$
+                AggregateSymbol sumCountAgg = new AggregateSymbol(NonReserved.SUM, false, countAgg); //$NON-NLS-1$
 
                 Expression convertedSum = new Function(FunctionLibrary.CONVERT, new Expression[] {sumSumAgg, new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()))});
                 Expression convertCount = new Function(FunctionLibrary.CONVERT, new Expression[] {sumCountAgg, new Constant(DataTypeManager.getDataTypeName(partitionAgg.getType()))});
@@ -888,13 +888,13 @@
                 nestedAggregates.add(sumAgg);
             } else if (partitionAgg.isEnhancedNumeric()) {
             	//e.g. STDDEV_SAMP := CASE WHEN COUNT(X) > 1 THEN SQRT((SUM(X^2) - SUM(X)^2/COUNT(X))/(COUNT(X) - 1))
-            	AggregateSymbol countAgg = new AggregateSymbol("stagedAgg", NonReserved.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
-                AggregateSymbol sumAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
-                AggregateSymbol sumSqAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, new Function(SourceSystemFunctions.POWER, new Expression[] {partitionAgg.getExpression(), new Constant(2)})); //$NON-NLS-1$
+            	AggregateSymbol countAgg = new AggregateSymbol(NonReserved.COUNT, false, partitionAgg.getExpression()); //$NON-NLS-1$
+                AggregateSymbol sumAgg = new AggregateSymbol(NonReserved.SUM, false, partitionAgg.getExpression()); //$NON-NLS-1$
+                AggregateSymbol sumSqAgg = new AggregateSymbol(NonReserved.SUM, false, new Function(SourceSystemFunctions.POWER, new Expression[] {partitionAgg.getExpression(), new Constant(2)})); //$NON-NLS-1$
                 
-                AggregateSymbol sumSumAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, sumAgg); //$NON-NLS-1$
-                AggregateSymbol sumCountAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, countAgg); //$NON-NLS-1$
-                AggregateSymbol sumSumSqAgg = new AggregateSymbol("stagedAgg", NonReserved.SUM, false, sumSqAgg); //$NON-NLS-1$
+                AggregateSymbol sumSumAgg = new AggregateSymbol(NonReserved.SUM, false, sumAgg); //$NON-NLS-1$
+                AggregateSymbol sumCountAgg = new AggregateSymbol(NonReserved.SUM, false, countAgg); //$NON-NLS-1$
+                AggregateSymbol sumSumSqAgg = new AggregateSymbol(NonReserved.SUM, false, sumSqAgg); //$NON-NLS-1$
                 
                 Expression convertedSum = new Function(FunctionLibrary.CONVERT, new Expression[] {sumSumAgg, new Constant(DataTypeManager.DefaultDataTypes.DOUBLE)});
 
@@ -926,7 +926,7 @@
                 nestedAggregates.add(sumSqAgg);
             } else {
                 //AGG(X) -> AGG(AGG(X))
-                newExpression = new AggregateSymbol("stagedAgg", aggFunction.name(), false, partitionAgg); //$NON-NLS-1$
+                newExpression = new AggregateSymbol(aggFunction.name(), false, partitionAgg); //$NON-NLS-1$
                 nestedAggregates.add(partitionAgg);
             }
 

Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -1224,7 +1224,7 @@
 	    		if (criteria.getOperator() == CompareCriteria.GT || criteria.getOperator() == CompareCriteria.GE) {
 	    			type = Type.MIN;
 	    		}
-	    		q.getSelect().addSymbol(new AggregateSymbol(type.name(), type.name(), false, expr));
+	    		q.getSelect().addSymbol(new AggregateSymbol(type.name(), false, expr));
 	    		cc.setRightExpression(new ScalarSubquery(q));
 				cc.setOperator(criteria.getOperator());
 	    		return rewriteCriteria(cc);
@@ -2026,6 +2026,9 @@
     }
     
 	private Expression rewriteFunction(Function function) throws TeiidComponentException, TeiidProcessingException{
+		if (function.isAggregate()) {
+			//AggregateSymbol as = new AggregateSymbol(function.getName(), aggregateFunction, isDistinct, expression)
+		}
 		//rewrite alias functions
 		String functionLowerName = function.getName().toLowerCase();
 		String actualName =ALIASED_FUNCTIONS.get(functionLowerName);

Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -454,6 +454,6 @@
     public boolean hasAggregates() {
     	return getGroupBy() != null 
     	|| getHaving() != null 
-    	|| !AggregateSymbolCollectorVisitor.getAggregates(getSelect(), false).isEmpty();
+    	|| !AggregateSymbolCollectorVisitor.getAllAggregates(getSelect()).isEmpty();
     }
 }  // END CLASS

Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -40,11 +40,7 @@
  *
  * <p>The type of an aggregate symbol depends on the function and the type of the underlying
  * expression.  The type of a COUNT function is ALWAYS integer.  MIN and MAX functions take the
- * type of their contained expression.  AVG and SUM vary depending on the type of the expression.
- * If the expression is of a type other than biginteger, the aggregate function returns type long.
- * For the case of biginteger, the aggregate function returns type biginteger.  Similarly, all
- * floating point expressions not of type bigdecimal return type double and bigdecimal maps to
- * bigdecimal.</p>
+ * type of their contained expression.</p>
  */
 public class AggregateSymbol extends Function implements DerivedExpression {
 	
@@ -66,7 +62,8 @@
 		VAR_SAMP,
 		RANK,
 		DENSE_RANK,
-		ROW_NUMBER;
+		ROW_NUMBER,
+		USER_DEFINED;
 	}
 
 	private Type aggregate;
@@ -115,14 +112,17 @@
     
 	/**
 	 * Construct an aggregate symbol with all given data.
-	 * @param name Name of the function
 	 * @param aggregateFunction Aggregate function type ({@link org.teiid.language.SQLConstants.NonReserved#COUNT}, etc)
 	 * @param isDistinct True if DISTINCT flag is set
 	 * @param expression Contained expression
 	 */
-	public AggregateSymbol(String name, String aggregateFunction, boolean isDistinct, Expression expression) {
-		super(name, expression == null?new Expression[0]:new Expression[] {expression});
-		this.aggregate = Type.valueOf(aggregateFunction);
+	public AggregateSymbol(String aggregateFunction, boolean isDistinct, Expression expression) {
+		super(aggregateFunction, expression == null?new Expression[0]:new Expression[] {expression});
+		try {
+			this.aggregate = Type.valueOf(aggregateFunction.toUpperCase());
+		} catch (IllegalArgumentException e) {
+			this.aggregate = Type.USER_DEFINED;
+		}
 		this.distinct = isDistinct;
 	}
 	
@@ -335,12 +335,13 @@
 		this.isWindowed = isWindowed;
 	}
 	
+	@Deprecated
 	public Expression getExpression() {
 		if (this.getArgs().length == 0) {
 			return null;
 		}
 		if (this.getArgs().length > 1) {
-			throw new AssertionError("getExpression should not be used with a non-unary aggregate");
+			throw new AssertionError("getExpression should not be used with a non-unary aggregate"); //$NON-NLS-1$
 		}
 		return this.getArg(0);
 	}

Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -242,6 +242,10 @@
 		return copy;	
 	}
 	
+	public boolean isAggregate() {
+		return getFunctionDescriptor().getMethod().getAggregateAttributes() != null;
+	}
+	
 	/**
 	 * Return string representation of the function.
 	 * @return String representation

Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -33,6 +33,7 @@
 import org.teiid.query.sql.symbol.AggregateSymbol;
 import org.teiid.query.sql.symbol.ElementSymbol;
 import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
 import org.teiid.query.sql.symbol.WindowFunction;
 
 
@@ -71,6 +72,7 @@
     private Collection<? super AggregateSymbol> aggregates;
     private Collection<? super ElementSymbol> otherElements;
     private Collection<? super WindowFunction> windowFunctions;
+	private Collection<? super Function> aggregateFunctions;
     
 	public AggregateSymbolCollectorVisitor(Collection<? super AggregateSymbol> aggregates, Collection<? super ElementSymbol> elements) { 
         this.aggregates = aggregates;
@@ -83,6 +85,13 @@
         }
     }
     
+    @Override
+    public void visit(Function obj) {
+    	if (aggregateFunctions != null && obj.isAggregate()) {
+            this.aggregateFunctions.add(obj);
+        }
+    }
+    
     public void visit(WindowFunction windowFunction) {
     	if (this.windowFunctions != null) {
     		this.windowFunctions.add(windowFunction);
@@ -107,6 +116,18 @@
         asn.visitNode(obj);
     }
 
+    public static final Collection<Function> getAllAggregates(LanguageObject obj) {
+    	if (obj == null) {
+    		return Collections.emptyList();
+    	}
+        Collection<Function> aggregates = new ArrayList<Function>();    
+        AggregateSymbolCollectorVisitor visitor = new AggregateSymbolCollectorVisitor(aggregates, null);
+        visitor.aggregateFunctions = aggregates;
+        AggregateStopNavigator asn = new AggregateStopNavigator(visitor, null, null);
+        obj.acceptVisitor(asn);
+        return aggregates;
+    }
+    
     public static final Collection<AggregateSymbol> getAggregates(LanguageObject obj, boolean removeDuplicates) {
     	if (obj == null) {
     		return Collections.emptyList();

Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -122,6 +122,9 @@
     }
     
     public void visit(AggregateSymbol obj) {
+    	if (obj.getFunctionDescriptor() != null) {
+    		this.setDeterminismLevel(obj.getFunctionDescriptor().getDeterministic());
+    	}
 		evaluationNotPossible(EvaluationLevel.PUSH_DOWN);
     }
     

Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -1082,12 +1082,12 @@
             append(" "); //$NON-NLS-1$
         }
 
-        if (obj.getExpression() == null) {
+        if (obj.getArgs().length == 0) {
         	if (obj.getAggregateFunction() == Type.COUNT) {
         		append(Tokens.ALL_COLS);
         	}
         } else {
-            visitNode(obj.getExpression());
+            registerNodes(obj.getArgs(), 0);
         }
 
         if (obj.getOrderBy() != null) {

Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-03-06 10:58:59 UTC (rev 3915)
@@ -1028,3 +1028,6 @@
 TEIID30581=Invalid table {0}.  A table must have 1 or more columns. 
 
 TEIID30590=Transaction Is null
+
+TEIID30600=User defined aggregate function "{0}" method "{1}" must not be static.
+TEIID30601=User defined aggregate function "{0}" class "{1}" does not implement {2}
\ No newline at end of file

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestAggregateImpl.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -43,10 +43,9 @@
     }
 
     public static AggregateFunction example(String name, String functionName, boolean distinct, int value) throws Exception {
-        AggregateSymbol symbol = new AggregateSymbol(name,
-                                                     functionName,
+        AggregateSymbol symbol = new AggregateSymbol(functionName,
                                                      distinct,
-                                                      new Constant(new Integer(value)));
+                                                     new Constant(new Integer(value)));
         return TstLanguageBridgeFactory.factory.translate(symbol);
         
     }

Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -187,7 +187,7 @@
         BasicSourceCapabilities caps = new BasicSourceCapabilities();
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -199,7 +199,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -211,7 +211,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -223,7 +223,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -235,7 +235,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -247,7 +247,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.COUNT, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -258,7 +258,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -269,7 +269,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.SUM, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -280,7 +280,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -291,7 +291,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.AVG, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -302,7 +302,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -313,7 +313,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.MIN, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -324,7 +324,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -335,7 +335,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.MAX, false, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    
@@ -347,7 +347,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, false);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, false); 
     }    
@@ -359,7 +359,7 @@
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
         caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, true);
         
-        AggregateSymbol aggregate = new AggregateSymbol("expr", NonReserved.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
+        AggregateSymbol aggregate = new AggregateSymbol(NonReserved.MAX, true, new ElementSymbol("x")); //$NON-NLS-1$ //$NON-NLS-2$
         
         helpTestSupportsAggregateFunction(caps, aggregate, true); 
     }    

Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -1189,7 +1189,7 @@
 
 		Select select = new Select();
 		select.addSymbol(new AliasSymbol("c",  //$NON-NLS-1$
-			new AggregateSymbol("c", "COUNT", false, new ElementSymbol("a", false)))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new AggregateSymbol("COUNT", false, new ElementSymbol("a", false)))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 		
 				
 		Query query = new Query();
@@ -1208,7 +1208,7 @@
 
         Select select = new Select();
         select.addSymbol(new AliasSymbol("c",  //$NON-NLS-1$
-            new AggregateSymbol("c", "COUNT", false, new ElementSymbol("a", false)))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            new AggregateSymbol("COUNT", false, new ElementSymbol("a", false)))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         
                 
         Query query = new Query();
@@ -1232,7 +1232,7 @@
 		groupBy.addSymbol(new ElementSymbol("a")); //$NON-NLS-1$
 		
 		Criteria having = new CompareCriteria(
-			new AggregateSymbol("count", "COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new AggregateSymbol("COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 			CompareCriteria.GT,
 			new Constant(new Integer(0)) );
 				
@@ -1263,7 +1263,7 @@
 		CompoundCriteria having = new CompoundCriteria();
 		having.setOperator(CompoundCriteria.AND);
 		having.addCriteria(new CompareCriteria(
-			new AggregateSymbol("count", "COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			new AggregateSymbol("COUNT", false, new ElementSymbol("b", false)), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 			CompareCriteria.GT,
 			new Constant(new Integer(0)) ));
 		having.addCriteria(new CompareCriteria(
@@ -1303,8 +1303,8 @@
         from.addGroup(g);
 
         Select select = new Select();
-        AggregateSymbol agg1 = new AggregateSymbol("count", "COUNT", false, new ElementSymbol("a", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        AggregateSymbol agg2 = new AggregateSymbol("sum", "SUM", false, new ElementSymbol("a", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        AggregateSymbol agg1 = new AggregateSymbol("COUNT", false, new ElementSymbol("a", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        AggregateSymbol agg2 = new AggregateSymbol("SUM", false, new ElementSymbol("a", false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         Function f = new Function("*", new Expression[] { agg1, agg2 }); //$NON-NLS-1$
         AliasSymbol alias = new AliasSymbol("c", f); //$NON-NLS-1$
         select.addSymbol(alias);        
@@ -4981,7 +4981,7 @@
     
     @Test public void testXmlAggWithOrderBy() throws Exception {
         String sql = "SELECT xmlAgg(1 order by e2)"; //$NON-NLS-1$
-        AggregateSymbol as = new AggregateSymbol("foo", Reserved.XMLAGG, false, new Constant(1));
+        AggregateSymbol as = new AggregateSymbol(Reserved.XMLAGG, false, new Constant(1));
         as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2"))));
         Query query = new Query();
         query.setSelect(new Select(Arrays.asList(as)));
@@ -4998,7 +4998,7 @@
         tf.setDelimiter(new Character(','));
         tf.setIncludeHeader(true);
         
-        AggregateSymbol as = new AggregateSymbol("foo", NonReserved.TEXTAGG, false, tf);
+        AggregateSymbol as = new AggregateSymbol(NonReserved.TEXTAGG, false, tf);
         as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2"))));
         
         Query query = new Query();
@@ -5010,7 +5010,7 @@
     
     @Test public void testArrayAggWithOrderBy() throws Exception {
         String sql = "SELECT array_agg(1 order by e2)"; //$NON-NLS-1$
-        AggregateSymbol as = new AggregateSymbol("foo", Reserved.ARRAY_AGG, false, new Constant(1));
+        AggregateSymbol as = new AggregateSymbol(Reserved.ARRAY_AGG, false, new Constant(1));
         as.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("e2"))));
         Query query = new Query();
         query.setSelect(new Select(Arrays.asList(as)));
@@ -5019,7 +5019,7 @@
     
     @Test public void testArrayAggWithIndexing() throws Exception {
         String sql = "SELECT (array_agg(1))[1]"; //$NON-NLS-1$
-        AggregateSymbol as = new AggregateSymbol("foo", Reserved.ARRAY_AGG, false, new Constant(1));
+        AggregateSymbol as = new AggregateSymbol(Reserved.ARRAY_AGG, false, new Constant(1));
         Query query = new Query();
         query.setSelect(new Select(Arrays.asList(new Function("array_get", new Expression[] {as, new Constant(1)}))));
         helpTest(sql, "SELECT array_get(ARRAY_AGG(1), 1)", query);
@@ -5172,7 +5172,7 @@
     @Test public void testAggFilter() throws Exception {
     	String sql = "select count(*) filter (where x = 1) from g";
     	Query query = new Query();
-    	AggregateSymbol aggregateSymbol = new AggregateSymbol("count", AggregateSymbol.Type.COUNT.name(), false, null);
+    	AggregateSymbol aggregateSymbol = new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null);
     	aggregateSymbol.setCondition(new CompareCriteria(new ElementSymbol("x"), CompareCriteria.EQ, new Constant(1)));
     	query.setSelect(new Select(Arrays.asList(aggregateSymbol)));
     	query.setFrom(new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("g")))));
@@ -5183,7 +5183,7 @@
     	String sql = "select row_number() over (partition by x order by y) from g";
     	Query query = new Query();
     	WindowFunction wf = new WindowFunction();
-    	wf.setFunction(new AggregateSymbol("expr", "ROW_NUMBER", false, null));
+    	wf.setFunction(new AggregateSymbol("ROW_NUMBER", false, null));
     	WindowSpecification ws = new WindowSpecification();
     	ws.setPartition(new ArrayList<Expression>(Arrays.asList(new ElementSymbol("x"))));
     	ws.setOrderBy(new OrderBy(Arrays.asList(new ElementSymbol("y"))));

Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -139,17 +139,17 @@
 		ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
 		col2.setType(Integer.class);
 		outputElements.add(col1);
-		outputElements.add(new AggregateSymbol("countAll", "COUNT", false, null)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("count", "COUNT", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("countDist", "COUNT", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("sum", "SUM", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("sumDist", "SUM", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("avg", "AVG", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("avgDist", "AVG", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("min", "MIN", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("minDist", "MIN", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("max", "MAX", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
-		outputElements.add(new AggregateSymbol("maxDist", "MAX", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("COUNT", false, null)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("COUNT", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("COUNT", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("SUM", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("SUM", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("AVG", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("AVG", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("MIN", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("MIN", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("MAX", false, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+		outputElements.add(new AggregateSymbol("MAX", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
 		node.setElements(outputElements);
 		
 		List groupingElements = new ArrayList();
@@ -228,8 +228,8 @@
         // Set up
         GroupingNode node = new GroupingNode(1);        
         List outputElements = new ArrayList();
-        outputElements.add(new AggregateSymbol("bigSum", "SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
-        outputElements.add(new AggregateSymbol("bigAvg", "AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
         node.setElements(outputElements);
         
         CommandContext context = new CommandContext("pid", "test", null, null, 1);               //$NON-NLS-1$ //$NON-NLS-2$
@@ -264,8 +264,8 @@
         GroupingNode node = new GroupingNode(1);        
         List outputElements = new ArrayList();
         outputElements.add(col1);
-        outputElements.add(new AggregateSymbol("bigSum", "SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
-        outputElements.add(new AggregateSymbol("bigAvg", "AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
         node.setElements(outputElements);
         
         // Set grouping elements to null 
@@ -312,9 +312,9 @@
         func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
         
         outputElements.add(col1);
-        outputElements.add(new AggregateSymbol("count", "COUNT", false, func)); //$NON-NLS-1$ //$NON-NLS-2$
-        outputElements.add(new AggregateSymbol("sum", "SUM", false, func)); //$NON-NLS-1$ //$NON-NLS-2$
-        outputElements.add(new AggregateSymbol("sumDist", "SUM", true, func)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("COUNT", false, func)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("SUM", false, func)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("SUM", true, func)); //$NON-NLS-1$ //$NON-NLS-2$
         node.setElements(outputElements);
         
         List groupingElements = new ArrayList();
@@ -357,8 +357,8 @@
         // Set up
         GroupingNode node = new GroupingNode(1);        
         List outputElements = new ArrayList();
-        outputElements.add(new AggregateSymbol("bigSum", "SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
-        outputElements.add(new AggregateSymbol("bigAvg", "AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("SUM", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("AVG", false, bigDecimal)); //$NON-NLS-1$ //$NON-NLS-2$
         node.setElements(outputElements);
         
         // Set grouping elements to null 
@@ -428,7 +428,7 @@
         ElementSymbol col2 = new ElementSymbol("col2"); //$NON-NLS-1$
         col2.setType(Integer.class);
         outputElements.add(col1);
-        outputElements.add(new AggregateSymbol("countDist", "COUNT", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
+        outputElements.add(new AggregateSymbol("COUNT", true, col2)); //$NON-NLS-1$ //$NON-NLS-2$
         node.setElements(outputElements);
         
         List groupingElements = new ArrayList();

Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -76,105 +76,105 @@
 	// ################################## ACTUAL TESTS ################################
 	
 	public void testParser1() {
-		AggregateSymbol as = new AggregateSymbol("count", NonReserved.COUNT, false, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol(NonReserved.COUNT, false, sampleElement()); //$NON-NLS-1$
 		helpParser(as, "COUNT(m.g.c)"); //$NON-NLS-1$
 	}
 
 	public void testParser2() {
-		AggregateSymbol as = new AggregateSymbol("count", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		helpParser(as, "COUNT(DISTINCT m.g.c)"); //$NON-NLS-1$
 	}
 
 	public void testParser3() {
-		AggregateSymbol as = new AggregateSymbol("x", NonReserved.MIN, false, sampleConstant()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol(NonReserved.MIN, false, sampleConstant()); //$NON-NLS-1$
 		helpParser(as, "MIN(5)"); //$NON-NLS-1$
 	}
 
 	public void testParser4() {
-		AggregateSymbol as = new AggregateSymbol("x", NonReserved.MAX, false, sampleFunction()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol(NonReserved.MAX, false, sampleFunction()); //$NON-NLS-1$
 		helpParser(as, "MAX((m.g.c + 5))"); //$NON-NLS-1$
 	}
 
 	public void testParser5() {
-		AggregateSymbol as = new AggregateSymbol("x", NonReserved.COUNT, false, null); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
 		helpParser(as, "COUNT(*)"); //$NON-NLS-1$
 	}
 		
 	public void testEquals1() { 
-		AggregateSymbol as = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		helpEquals(as, as, true);		
 	}
 
 	public void testEquals2() { 
-		AggregateSymbol as1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		AggregateSymbol as2 = (AggregateSymbol) as1.clone();
 		helpEquals(as1, as2, true);		
 	}
 
     //just changing the name of an aggregatesymbol doesn't matter
 	public void testEquals3() { 
-		AggregateSymbol as1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol as2 = new AggregateSymbol("y", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol as2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		helpEquals(as1, as2, true);		
 	}
 	
 	public void testEquals4() { 
-		AggregateSymbol as1 = new AggregateSymbol("count", NonReserved.COUNT, false, null); //$NON-NLS-1$
+		AggregateSymbol as1 = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
 		AggregateSymbol as2 = (AggregateSymbol) as1.clone();
 		helpEquals(as1, as2, true);		
 	}
 
 	public void testSelfEquivalence(){
-		AggregateSymbol test = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		int equals = 0;
 		UnitTestUtil.helpTestEquivalence(equals, test, test);
 	}
 
 	public void testEquivalence(){
-		AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		int equals = 0;
 		UnitTestUtil.helpTestEquivalence(equals, test1, test2);
 	}
     
     public void testEquivalenceCountStar(){
-        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, false, null); //$NON-NLS-1$
-        AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
+        AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
         int equals = 0;
         UnitTestUtil.helpTestEquivalence(equals, test1, test2);
     }
 
 	public void testEquivalenceCaseInsens(){
-		AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol test2 = new AggregateSymbol("X", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
 		int equals = 0;
 		UnitTestUtil.helpTestEquivalence(equals, test1, test2);
 	}
     
     public void testNonEquivalenceUsingDiffElements(){ 
-        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$ 
-        AggregateSymbol test2 = new AggregateSymbol("X", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$ 
+        AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$ 
+        AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$ 
         int equals = -1; 
         UnitTestUtil.helpTestEquivalence(equals, test1, test2); 
     } 
 	
 	public void testNonEquivalence(){
-		AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
-		AggregateSymbol test2 = new AggregateSymbol("y", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
+		AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+		AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
 		int equals = -1;
 		UnitTestUtil.helpTestEquivalence(equals, test1, test2);
 	}
     
     public void testNonEquivalence1(){
-        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
-        AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
+        AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement()); //$NON-NLS-1$
+        AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
         int equals = -1;
         UnitTestUtil.helpTestEquivalence(equals, test1, test2);
     }
     
     public void testNonEquivalence2(){
-        AggregateSymbol test1 = new AggregateSymbol("x", NonReserved.MAX, true, sampleElement()); //$NON-NLS-1$
-        AggregateSymbol test2 = new AggregateSymbol("x", NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
+        AggregateSymbol test1 = new AggregateSymbol(NonReserved.MAX, true, sampleElement()); //$NON-NLS-1$
+        AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement2()); //$NON-NLS-1$
         int equals = -1;
         UnitTestUtil.helpTestEquivalence(equals, test1, test2);
     }

Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -207,10 +207,10 @@
      */
     @Test public void testRecursionDetection() {
     	ElementSymbol e1 = new ElementSymbol("g1.e1"); //$NON-NLS-1$
-    	AggregateSymbol a1 = new AggregateSymbol("x", NonReserved.SUM, false, e1); //$NON-NLS-1$
+    	AggregateSymbol a1 = new AggregateSymbol(NonReserved.SUM, false, e1); //$NON-NLS-1$
     	Function f = new Function(SourceSystemFunctions.ADD_OP, new Expression[] {a1, a1});
     	HashMap<AggregateSymbol, AggregateSymbol> map = new HashMap<AggregateSymbol, AggregateSymbol>();
-    	map.put(a1, new AggregateSymbol("x", NonReserved.SUM, false, a1)); //$NON-NLS-1$
+    	map.put(a1, new AggregateSymbol(NonReserved.SUM, false, a1)); //$NON-NLS-1$
     	ExpressionMappingVisitor.mapExpressions(f, map);
         assertEquals("(SUM(SUM(g1.e1)) + SUM(SUM(g1.e1)))", f.toString()); //$NON-NLS-1$
     }

Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java	2012-03-06 04:07:16 UTC (rev 3914)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java	2012-03-06 10:58:59 UTC (rev 3915)
@@ -945,37 +945,37 @@
 	}
 	
 	@Test public void testAggregateSymbol1() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.COUNT, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "COUNT('abc')"); //$NON-NLS-1$
 	}
 	
 	@Test public void testAggregateSymbol2() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.COUNT, true, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "COUNT(DISTINCT 'abc')"); //$NON-NLS-1$
 	}
 	
 	@Test public void testAggregateSymbol3() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.COUNT, false, null); //$NON-NLS-1$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.COUNT, false, null); //$NON-NLS-1$
 		helpTest(agg, "COUNT(*)"); //$NON-NLS-1$
 	}
 	
 	@Test public void testAggregateSymbol4() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.AVG, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.AVG, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "AVG('abc')"); //$NON-NLS-1$
 	}
 	
 	@Test public void testAggregateSymbol5() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.SUM, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.SUM, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "SUM('abc')"); //$NON-NLS-1$
 	}
 	
 	@Test public void testAggregateSymbol6() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.MIN, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.MIN, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "MIN('abc')"); //$NON-NLS-1$
 	}
 	
 	@Test public void testAggregateSymbol7() {
-		AggregateSymbol agg = new AggregateSymbol("abc", NonReserved.MAX, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
+		AggregateSymbol agg = new AggregateSymbol(NonReserved.MAX, false, new Constant("abc")); //$NON-NLS-1$ //$NON-NLS-2$
 		helpTest(agg, "MAX('abc')"); //$NON-NLS-1$
 	}
 	



More information about the teiid-commits mailing list