Package org.teiid.query.sql.symbol
Class AggregateSymbol
- java.lang.Object
-
- org.teiid.query.sql.symbol.Function
-
- org.teiid.query.sql.symbol.AggregateSymbol
-
- All Implemented Interfaces:
Cloneable,LanguageObject,DerivedExpression,Expression,NamedExpression
public class AggregateSymbol extends Function implements DerivedExpression, NamedExpression
An aggregate symbol represents an aggregate function. 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAggregateSymbol.Type-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
Fields Modifier and Type Field Description static booleanLONG_RANKS
-
Constructor Summary
Constructors Modifier Constructor Description AggregateSymbol(String aggregateFunction, boolean isDistinct, Expression expression)Construct an aggregate symbol with all given data.AggregateSymbol(String aggregateFunction, boolean isDistinct, Expression[] args, OrderBy orderBy)protectedAggregateSymbol(String name, AggregateSymbol.Type aggregateFunction, boolean isDistinct, Expression[] args)Constructor used for cloning
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacceptVisitor(LanguageVisitor visitor)Method for accepting a visitor.static booleanareAggregatesCardinalityDependent(Collection<AggregateSymbol> aggs)booleancanStage()Objectclone()Return a deep copy of this objectbooleanequals(Object obj)Compare for equalityAggregateSymbol.TypegetAggregateFunction()Get the aggregate function type - this will map to one of the reserved words for the aggregate functions.ExpressiongetCondition()OrderBygetOrderBy()Class<?>getType()Get the type of the symbol, which depends on the aggregate function and the type of the contained expressioninthashCode()Compute hash code for the object - based on name and hashcode of first arg (if there is one)booleanisAnalytical()booleanisBoolean()booleanisCardinalityDependent()booleanisCount()booleanisDistinct()Get the distinct flag.booleanisEnhancedNumeric()booleanisRanking()booleanisRowValueFunction()booleanisWindowed()booleanrespectsNulls()voidsetAggregateFunction(AggregateSymbol.Type aggregateFunction)Set the aggregate function.voidsetCondition(Expression condition)voidsetDistinct(boolean distinct)voidsetOrderBy(OrderBy orderBy)voidsetWindowed(boolean isWindowed)-
Methods inherited from class org.teiid.query.sql.symbol.Function
getArg, getArgs, getFunctionDescriptor, getName, getPushdownFunction, insertConversion, isAggregate, isCalledWithVarArgArrayParam, isEval, isImplicit, makeImplicit, setArgs, setCalledWithVarArgArrayParam, setEval, setFunctionDescriptor, setImplicit, setName, setPushdownFunction, setType, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.teiid.query.sql.symbol.NamedExpression
getName
-
-
-
-
Constructor Detail
-
AggregateSymbol
protected AggregateSymbol(String name, AggregateSymbol.Type aggregateFunction, boolean isDistinct, Expression[] args)
Constructor used for cloning- Parameters:
name-aggregateFunction-- Since:
- 4.3
-
AggregateSymbol
public AggregateSymbol(String aggregateFunction, boolean isDistinct, Expression expression)
Construct an aggregate symbol with all given data.- Parameters:
aggregateFunction- Aggregate function type (SQLConstants.NonReserved.COUNT, etc)isDistinct- True if DISTINCT flag is setexpression- Contained expression
-
AggregateSymbol
public AggregateSymbol(String aggregateFunction, boolean isDistinct, Expression[] args, OrderBy orderBy)
-
-
Method Detail
-
setAggregateFunction
public void setAggregateFunction(AggregateSymbol.Type aggregateFunction)
Set the aggregate function. If the aggregate function is an invalid value, an IllegalArgumentException is thrown.- Parameters:
aggregateFunction- Aggregate function type- See Also:
SQLConstants.NonReserved.COUNT,SQLConstants.NonReserved.SUM,SQLConstants.NonReserved.AVG,SQLConstants.NonReserved.MIN,SQLConstants.NonReserved.MAX
-
getAggregateFunction
public AggregateSymbol.Type getAggregateFunction()
Get the aggregate function type - this will map to one of the reserved words for the aggregate functions.- Returns:
- Aggregate function type
-
isRowValueFunction
public boolean isRowValueFunction()
-
isDistinct
public boolean isDistinct()
Get the distinct flag. If true, aggregate symbol will remove duplicates during computation.- Returns:
- True if duplicates should be removed during computation
-
setDistinct
public void setDistinct(boolean distinct)
-
getType
public Class<?> getType()
Get the type of the symbol, which depends on the aggregate function and the type of the contained expression- Specified by:
getTypein interfaceExpression- Overrides:
getTypein classFunction- Returns:
- Type of the symbol
-
isRanking
public boolean isRanking()
-
isCount
public boolean isCount()
-
isAnalytical
public boolean isAnalytical()
-
isBoolean
public boolean isBoolean()
-
isEnhancedNumeric
public boolean isEnhancedNumeric()
-
acceptVisitor
public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface:LanguageObjectMethod for accepting a visitor. It is the responsibility of the language object to call back on the visitor.- Specified by:
acceptVisitorin interfaceLanguageObject- Overrides:
acceptVisitorin classFunction- Parameters:
visitor- Visitor being used
-
getOrderBy
public OrderBy getOrderBy()
-
setOrderBy
public void setOrderBy(OrderBy orderBy)
-
clone
public Object clone()
Return a deep copy of this object- Specified by:
clonein interfaceLanguageObject- Overrides:
clonein classFunction- Returns:
- Deep copy of the object
-
hashCode
public int hashCode()
Description copied from class:FunctionCompute hash code for the object - based on name and hashcode of first arg (if there is one)- Overrides:
hashCodein classFunction- Returns:
- Hash code
- See Also:
ExpressionSymbol.hashCode()
-
equals
public boolean equals(Object obj)
Description copied from class:FunctionCompare for equality- Overrides:
equalsin classFunction- Parameters:
obj- Other object to compare- Returns:
- Return true if objects are equivalent
- See Also:
ExpressionSymbol.equals(java.lang.Object)
-
isCardinalityDependent
public boolean isCardinalityDependent()
-
getCondition
public Expression getCondition()
-
setCondition
public void setCondition(Expression condition)
-
areAggregatesCardinalityDependent
public static boolean areAggregatesCardinalityDependent(Collection<AggregateSymbol> aggs)
-
respectsNulls
public boolean respectsNulls()
-
canStage
public boolean canStage()
-
isWindowed
public boolean isWindowed()
-
setWindowed
public void setWindowed(boolean isWindowed)
-
-