|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.metamatrix.query.sql.symbol.Symbol
com.metamatrix.query.sql.symbol.SelectSymbol
com.metamatrix.query.sql.symbol.SingleElementSymbol
com.metamatrix.query.sql.symbol.ExpressionSymbol
com.metamatrix.query.sql.symbol.AggregateSymbol
public class AggregateSymbol
An aggregate symbol represents an aggregate function in the SELECT or HAVING clauses. It
extends ExpressionSymbol as they have many things in common. The aggregate symbol is
typically something like SUM(stock.quantity * 2)
. There are five supported
aggregate functions: COUNT, SUM, AVG, MIN, and MAX. Aggregate functions contain an expression -
this data is managed by the super class, ExpressionSymbol. Aggregate functions may also
specify a DISTINCT flag to indicate that duplicates should be ignored. The DISTINCT flag
may be set for all five aggregate functions but is ignored for the computation of MIN and MAX.
One special use of an aggregate symbol is for the symbol COUNT(*)
. The * expression
is encoded by setting the expression to null. This may ONLY be used with the COUNT function.
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.
Field Summary |
---|
Fields inherited from class com.metamatrix.query.sql.symbol.SingleElementSymbol |
---|
SEPARATOR |
Constructor Summary | |
---|---|
|
AggregateSymbol(java.lang.String name,
java.lang.String aggregateFunction,
boolean isDistinct,
Expression expression)
Construct an aggregate symbol with all given data. |
protected |
AggregateSymbol(java.lang.String name,
java.lang.String canonicalName,
java.lang.String aggregateFunction,
boolean isDistinct,
Expression expression)
Constructor used for cloning |
Method Summary | |
---|---|
void |
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor. |
java.lang.Object |
clone()
Return a deep copy of this object |
boolean |
equals(java.lang.Object obj)
ExpressionSymbol matching is not based upon the name |
java.lang.String |
getAggregateFunction()
Get the aggregate function type - this will map to one of the reserved words for the aggregate functions. |
java.lang.Class |
getType()
Get the type of the symbol, which depends on the aggregate function and the type of the contained expression |
int |
hashCode()
Return a hash code for this symbol. |
boolean |
isDistinct()
Get the distinct flag. |
Methods inherited from class com.metamatrix.query.sql.symbol.ExpressionSymbol |
---|
getExpression, isDerivedExpression, isResolved, setDerivedExpression, setExpression |
Methods inherited from class com.metamatrix.query.sql.symbol.SingleElementSymbol |
---|
getShortCanonicalName, getShortName, getShortName |
Methods inherited from class com.metamatrix.query.sql.symbol.Symbol |
---|
getCanonical, getCanonicalName, getName, getOutputName, setName, setOutputName, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected AggregateSymbol(java.lang.String name, java.lang.String canonicalName, java.lang.String aggregateFunction, boolean isDistinct, Expression expression)
name
- canonicalName
- public AggregateSymbol(java.lang.String name, java.lang.String aggregateFunction, boolean isDistinct, Expression expression)
name
- Name of the functionaggregateFunction
- Aggregate function type (ReservedWords.COUNT
, etc)isDistinct
- True if DISTINCT flag is setexpression
- Contained expressionMethod Detail |
---|
public java.lang.String getAggregateFunction()
ReservedWords.COUNT
,
ReservedWords.SUM
,
ReservedWords.AVG
,
ReservedWords.MIN
,
ReservedWords.MAX
public boolean isDistinct()
public java.lang.Class getType()
getType
in interface Expression
getType
in class ExpressionSymbol
public void acceptVisitor(LanguageVisitor visitor)
LanguageObject
acceptVisitor
in interface LanguageObject
acceptVisitor
in class ExpressionSymbol
visitor
- Visitor being usedpublic java.lang.Object clone()
clone
in interface LanguageObject
clone
in class ExpressionSymbol
public int hashCode()
Symbol
hashCode
in class ExpressionSymbol
ExpressionSymbol.hashCode()
public boolean equals(java.lang.Object obj)
ExpressionSymbol
equals
in class ExpressionSymbol
obj
- Other object
ExpressionSymbol.equals(java.lang.Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |