@Override public WindowFunction clone() { WindowFunction clone = new WindowFunction(); clone.setFunction((AggregateSymbol) this.function.clone()); clone.setWindowSpecification(this.windowSpecification.clone()); return clone; }
@Override public void visit(WindowFunction obj) { preVisitVisitor(obj); visitNode(obj.getFunction()); visitNode(obj.getWindowSpecification()); postVisitVisitor(obj); }
elements.add(key); for (WindowFunctionInfo wfi : functions) { aggs.add(GroupingNode.initAccumulator(wfi.function.getFunction(), this, expressionIndexes)); Class<?> outputType = wfi.function.getType(); if (wfi.function.getFunction().getAggregateFunction() == Type.LEAD || wfi.function.getFunction().getAggregateFunction() == Type.LAG) { outputType = DataTypeManager.getArrayType(DataTypeManager.DefaultDataClasses.OBJECT);
private void addPartitionCount(int i, WindowFunction wf) { WindowFunction wf2 = new WindowFunction(); wf2.setFunction(new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null)); //clone the partitioning if any WindowSpecification clone = wf.getWindowSpecification().clone(); clone.setOrderBy(null); wf2.setWindowSpecification(clone); WindowSpecificationInfo wsi2 = getOrCreateWindowSpecInfo(clone); WindowFunctionInfo wfi2 = createWindowFunctionInfo(wf2); wfi2.outputIndex = i; wfi2.primaryFunction = wf; wsi2.functions.add(wfi2); }
private WindowFunctionInfo createWindowFunctionInfo(WindowFunction wf) { WindowFunctionInfo wfi = new WindowFunctionInfo(); wfi.function = wf; //collect the agg expressions for (Expression e : wf.getFunction().getArgs()) { GroupingNode.getIndex(e, expressionIndexes); } if (wf.getFunction().getOrderBy() != null) { for (OrderByItem item : wf.getFunction().getOrderBy().getOrderByItems()) { GroupingNode.getIndex(item.getSymbol(), expressionIndexes); } } if (wf.getFunction().getCondition() != null) { GroupingNode.getIndex(wf.getFunction().getCondition(), expressionIndexes); } return wfi; }
WindowSpecification spec = windowFunction.getWindowSpecification(); if (spec.getPartition() == null) { return null;
private void addPartitionCount(int i, WindowFunction wf) { WindowFunction wf2 = new WindowFunction(); wf2.setFunction(new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null)); //clone the partitioning if any WindowSpecification clone = wf.getWindowSpecification().clone(); clone.setOrderBy(null); wf2.setWindowSpecification(clone); WindowSpecificationInfo wsi2 = getOrCreateWindowSpecInfo(clone); WindowFunctionInfo wfi2 = createWindowFunctionInfo(wf2); wfi2.outputIndex = i; wfi2.primaryFunction = wf; wsi2.functions.add(wfi2); }
private WindowFunctionInfo createWindowFunctionInfo(WindowFunction wf) { WindowFunctionInfo wfi = new WindowFunctionInfo(); wfi.function = wf; //collect the agg expressions for (Expression e : wf.getFunction().getArgs()) { GroupingNode.getIndex(e, expressionIndexes); } if (wf.getFunction().getOrderBy() != null) { for (OrderByItem item : wf.getFunction().getOrderBy().getOrderByItems()) { GroupingNode.getIndex(item.getSymbol(), expressionIndexes); } } if (wf.getFunction().getCondition() != null) { GroupingNode.getIndex(wf.getFunction().getCondition(), expressionIndexes); } return wfi; }
WindowSpecification spec = windowFunction.getWindowSpecification(); if (spec.getPartition() == null) { return null;
@Override public WindowFunction clone() { WindowFunction clone = new WindowFunction(); clone.setFunction((AggregateSymbol) this.function.clone()); clone.setWindowSpecification(this.windowSpecification.clone()); return clone; }
@Override public void visit(WindowFunction obj) { preVisitVisitor(obj); visitNode(obj.getFunction()); visitNode(obj.getWindowSpecification()); postVisitVisitor(obj); }
/** * @param functions * @param specIndex * @param rowValues * @return */ private List<AggregateFunction> initializeAccumulators(List<WindowFunctionInfo> functions, int specIndex) { List<AggregateFunction> aggs = new ArrayList<AggregateFunction>(functions.size()); if (functions.isEmpty()) { return aggs; } List<ElementSymbol> elements = new ArrayList<ElementSymbol>(functions.size()); ElementSymbol key = new ElementSymbol("key"); //$NON-NLS-1$ key.setType(DataTypeManager.DefaultDataClasses.INTEGER); elements.add(key); for (WindowFunctionInfo wfi : functions) { AggregateFunction aggregateFunction = GroupingNode.initAccumulator(wfi.function.getFunction(), this, expressionIndexes); aggs.add(aggregateFunction); Class<?> outputType = aggregateFunction.getOutputType(wfi.function.getFunction()); ElementSymbol value = new ElementSymbol("val"); //$NON-NLS-1$ value.setType(outputType); elements.add(value); } valueMapping[specIndex] = this.getBufferManager().createSTree(elements, this.getConnectionID(), 1); return aggs; }
WindowSpecification spec = windowFunction.getWindowSpecification(); if (spec.getPartition() == null) { return null;
@Override public WindowFunction clone() { WindowFunction clone = new WindowFunction(); clone.setFunction((AggregateSymbol) this.function.clone()); clone.setWindowSpecification(this.windowSpecification.clone()); return clone; }
@Override public void visit(WindowFunction obj) { preVisitVisitor(obj); visitNode(obj.getFunction()); visitNode(obj.getWindowSpecification()); postVisitVisitor(obj); }
/** * @param functions * @param specIndex * @param rowValues * @return */ private List<AggregateFunction> initializeAccumulators(List<WindowFunctionInfo> functions, int specIndex) { List<AggregateFunction> aggs = new ArrayList<AggregateFunction>(functions.size()); if (functions.isEmpty()) { return aggs; } List<ElementSymbol> elements = new ArrayList<ElementSymbol>(functions.size()); ElementSymbol key = new ElementSymbol("key"); //$NON-NLS-1$ key.setType(DataTypeManager.DefaultDataClasses.INTEGER); elements.add(key); for (WindowFunctionInfo wfi : functions) { AggregateFunction aggregateFunction = GroupingNode.initAccumulator(wfi.function.getFunction(), this, expressionIndexes); aggs.add(aggregateFunction); Class<?> outputType = aggregateFunction.getOutputType(wfi.function.getFunction()); ElementSymbol value = new ElementSymbol("val"); //$NON-NLS-1$ value.setType(outputType); elements.add(value); } valueMapping[specIndex] = this.getBufferManager().createSTree(elements, this.getConnectionID(), 1); return aggs; }
if (expression instanceof WindowFunction) { WindowFunction wf = (WindowFunction)expression; WindowFrame windowFrame = wf.getWindowSpecification().getWindowFrame(); if (windowFrame != null) { if (Integer.valueOf(0).equals(windowFrame.getStart().getBound())) { && windowFrame.getStart().getBound() == null && windowFrame.getStart().getBoundMode() == BoundMode.PRECEDING) { wf.getWindowSpecification().setWindowFrame(null);
WindowFunction result = new WindowFunction(); WindowSpecification ws = new WindowSpecification(); result.setFunction((AggregateSymbol)agg); ws.setPartition(partitionList); ws.setOrderBy(orderBy); result.setWindowSpecification(ws); {if (true) return result;} throw new Error("Missing return statement in function");
@Override public void visit(WindowFunction windowFunction) { append(windowFunction.getFunction()); append(SPACE); append(OVER); append(SPACE); append(windowFunction.getWindowSpecification()); }
if (wfi.function.getFunction().getAggregateFunction() == Type.LEAD || wfi.function.getFunction().getAggregateFunction() == Type.LAG) { ArrayImpl array = (ArrayImpl)value; Object[] args = array.getValues(); List<?> newIdRow = Arrays.asList(rowId+(wfi.function.getFunction().getAggregateFunction() == Type.LAG?-offset:offset)); List<?> newValueRow = rowValueMapping[specIndex].find(newIdRow); if (newValueRow == null) {