private boolean canAddGrouping(LanguageObject lo) { for (AggregateSymbol as : AggregateSymbolCollectorVisitor.getAggregates(lo, false)) { if (as.isCount() || as.getAggregateFunction() == Type.TEXTAGG) { //these can be non-null for no rows. //TODO: could include udaf as well return false; } } return true; }
private boolean canAddGrouping(LanguageObject lo) { for (AggregateSymbol as : AggregateSymbolCollectorVisitor.getAggregates(lo, false)) { if (as.isCount() || as.getAggregateFunction() == Type.TEXTAGG) { //these can be non-null for no rows. //TODO: could include udaf as well return false; } } return true; }
private Map<Integer, Object> createAggregateMetadata(String shortColumnName, AggregateSymbol symbol) throws QueryMetadataException, TeiidComponentException { Type function = symbol.getAggregateFunction(); if(function == Type.MIN || function == Type.MAX){ Expression expression = symbol.getArg(0); if(expression instanceof ElementSymbol) { return createColumnMetadata(shortColumnName, expression); } } return createTypedMetadata(shortColumnName, symbol); }
private Map<Integer, Object> createAggregateMetadata(String shortColumnName, AggregateSymbol symbol) throws QueryMetadataException, TeiidComponentException { Type function = symbol.getAggregateFunction(); if(function == Type.MIN || function == Type.MAX){ Expression expression = symbol.getArg(0); if(expression instanceof ElementSymbol) { return createColumnMetadata(shortColumnName, expression); } } return createTypedMetadata(shortColumnName, symbol); }
private Map<Integer, Object> createAggregateMetadata(String shortColumnName, AggregateSymbol symbol) throws QueryMetadataException, TeiidComponentException { Type function = symbol.getAggregateFunction(); if(function == Type.MIN || function == Type.MAX){ Expression expression = symbol.getArg(0); if(expression instanceof ElementSymbol) { return createColumnMetadata(shortColumnName, expression); } } return createTypedMetadata(shortColumnName, symbol); }
private static boolean isCountStar(AggregateSymbol as) { return as.getAggregateFunction() == Type.COUNT && (as.getArgs().length == 0 || EvaluatableVisitor.willBecomeConstant(as.getArg(0))); }
private boolean isNonNull(Query query, Expression rightExpr) throws TeiidComponentException, QueryMetadataException { if (rightExpr instanceof ElementSymbol) { ElementSymbol es = (ElementSymbol)rightExpr; if (metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { return false; } if (!isSimpleJoin(query)) { return false; } } else if (rightExpr instanceof Constant) { if (((Constant)rightExpr).isNull()) { return false; } } else if (rightExpr instanceof AggregateSymbol) { AggregateSymbol as = (AggregateSymbol)rightExpr; if (as.getAggregateFunction() != Type.COUNT) { return false; } } else { return false; } return true; }
public boolean isCardinalityDependent() { if (isDistinct()) { return false; } switch (getAggregateFunction()) { case MAX: case MIN: case ANY: case SOME: case EVERY: return false; case USER_DEFINED: return !getFunctionDescriptor().getMethod().getAggregateAttributes().usesDistinctRows(); } return true; }
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)); } String name = symbol.getAggregateFunction().name(); if (symbol.getAggregateFunction() == AggregateSymbol.Type.USER_DEFINED) { name = symbol.getName(); } AggregateFunction af = new AggregateFunction(name, symbol.isDistinct(), params, symbol.getType()); af.setCondition(translate(symbol.getCondition())); af.setOrderBy(translate(symbol.getOrderBy(), false)); return af; }
public boolean isCardinalityDependent() { if (isDistinct()) { return false; } switch (getAggregateFunction()) { case MAX: case MIN: case ANY: case SOME: case EVERY: return false; case USER_DEFINED: return !getFunctionDescriptor().getMethod().getAggregateAttributes().usesDistinctRows(); } return true; }
public boolean isCardinalityDependent() { if (isDistinct()) { return false; } switch (getAggregateFunction()) { case MAX: case MIN: case ANY: case SOME: case EVERY: return false; case USER_DEFINED: return !getFunctionDescriptor().getMethod().getAggregateAttributes().usesDistinctRows(); } return true; }
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)); } String name = symbol.getAggregateFunction().name(); if (symbol.getFunctionDescriptor() != null) { name = Symbol.getShortName(symbol.getFunctionDescriptor().getName()); } else if (symbol.getAggregateFunction() == AggregateSymbol.Type.USER_DEFINED) { name = symbol.getName(); } else if (symbol.getAggregateFunction() == Type.COUNT_BIG && !supportsCountBig) { name = Type.COUNT.name(); } AggregateFunction af = new AggregateFunction(name, symbol.isDistinct(), params, symbol.getType()); af.setCondition(translate(symbol.getCondition())); af.setOrderBy(translate(symbol.getOrderBy(), false)); if (symbol.getFunctionDescriptor() != null) { af.setMetadataObject(symbol.getFunctionDescriptor().getMethod()); } return af; }
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)); } String name = symbol.getAggregateFunction().name(); if (symbol.getFunctionDescriptor() != null) { name = Symbol.getShortName(symbol.getFunctionDescriptor().getName()); } else if (symbol.getAggregateFunction() == AggregateSymbol.Type.USER_DEFINED) { name = symbol.getName(); } else if (symbol.getAggregateFunction() == Type.COUNT_BIG && !supportsCountBig) { name = Type.COUNT.name(); } AggregateFunction af = new AggregateFunction(name, symbol.isDistinct(), params, symbol.getType()); af.setCondition(translate(symbol.getCondition())); af.setOrderBy(translate(symbol.getOrderBy(), false)); if (symbol.getFunctionDescriptor() != null) { af.setMetadataObject(symbol.getFunctionDescriptor().getMethod()); } return af; }
/** * Return a deep copy of this object */ public Object clone() { AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs())); if (orderBy != null) { copy.setOrderBy(orderBy.clone()); } if (condition != null) { copy.setCondition((Expression) condition.clone()); } copy.isWindowed = this.isWindowed; copy.type = this.type; copy.setFunctionDescriptor(getFunctionDescriptor()); return copy; }
/** * Return a deep copy of this object */ public Object clone() { AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs())); if (orderBy != null) { copy.setOrderBy(orderBy.clone()); } if (condition != null) { copy.setCondition((Expression) condition.clone()); } copy.isWindowed = this.isWindowed; copy.type = this.type; copy.setFunctionDescriptor(getFunctionDescriptor()); return copy; }
/** * Return a deep copy of this object */ public Object clone() { AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs())); if (orderBy != null) { copy.setOrderBy(orderBy.clone()); } if (condition != null) { copy.setCondition((Expression) condition.clone()); } copy.isWindowed = this.isWindowed; copy.type = this.type; copy.setFunctionDescriptor(getFunctionDescriptor()); return copy; }
boolean processEachFrame() { for (WindowFunctionInfo info : functions) { //because getting the output is destructive, we need //to process these for each frame //TODO: udfs switch (info.function.getFunction().getAggregateFunction()) { case XMLAGG: case STRING_AGG: case JSONARRAY_AGG: case TEXTAGG: case NTH_VALUE: //the logic needs to know the frame start/end if (windowFrame == null) { //use the default frame range unbounded preceding this.windowFrame = new WindowFrame(FrameMode.RANGE); this.windowFrame.setStart(new FrameBound(BoundMode.PRECEDING)); } return true; } } return windowFrame != null && (windowFrame.getStart().getBound() != null || windowFrame.getStart().getBoundMode() == BoundMode.CURRENT_ROW || (windowFrame.getEnd() != null && windowFrame.getEnd().getBound() != null)); } }
boolean processEachFrame() { for (WindowFunctionInfo info : functions) { //because getting the output is destructive, we need //to process these for each frame //TODO: udfs switch (info.function.getFunction().getAggregateFunction()) { case XMLAGG: case STRING_AGG: case JSONARRAY_AGG: case TEXTAGG: case NTH_VALUE: //the logic needs to know the frame start/end if (windowFrame == null) { //use the default frame range unbounded preceding this.windowFrame = new WindowFrame(FrameMode.RANGE); this.windowFrame.setStart(new FrameBound(BoundMode.PRECEDING)); } return true; } } return windowFrame != null && (windowFrame.getStart().getBound() != null || windowFrame.getStart().getBoundMode() == BoundMode.CURRENT_ROW || (windowFrame.getEnd() != null && windowFrame.getEnd().getBound() != null)); } }
append(DISTINCT); append(" "); //$NON-NLS-1$ } else if (obj.getAggregateFunction() == Type.USER_DEFINED) { if (obj.getAggregateFunction() == Type.COUNT) { append(Tokens.ALL_COLS);
append(DISTINCT); append(" "); //$NON-NLS-1$ } else if (obj.getAggregateFunction() == Type.USER_DEFINED) {