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)); } }
@Override public void visit(WindowFrame windowFrame) { append(windowFrame.getMode().name()); append(SPACE); if (windowFrame.getEnd() != null) { append(Reserved.BETWEEN); append(SPACE); } appendFrameBound(windowFrame.getStart()); if (windowFrame.getEnd() != null) { append(SPACE); append(Reserved.AND); append(SPACE); appendFrameBound(windowFrame.getEnd()); } }
@Override public void visit(WindowFrame windowFrame) { append(windowFrame.getMode().name()); append(SPACE); if (windowFrame.getEnd() != null) { append(Reserved.BETWEEN); append(SPACE); } appendFrameBound(windowFrame.getStart()); if (windowFrame.getEnd() != null) { append(SPACE); append(Reserved.AND); append(SPACE); appendFrameBound(windowFrame.getEnd()); } }
WindowFrame windowFrame = wf.getWindowSpecification().getWindowFrame(); if (windowFrame != null) { if (Integer.valueOf(0).equals(windowFrame.getStart().getBound())) { windowFrame.setStart(new FrameBound(BoundMode.CURRENT_ROW)); && windowFrame.getStart().getBound() == null && windowFrame.getStart().getBoundMode() == BoundMode.PRECEDING) {
WindowFrame windowFrame = wf.getWindowSpecification().getWindowFrame(); if (windowFrame != null) { if (Integer.valueOf(0).equals(windowFrame.getStart().getBound())) { windowFrame.setStart(new FrameBound(BoundMode.CURRENT_ROW)); && windowFrame.getStart().getBound() == null && windowFrame.getStart().getBoundMode() == BoundMode.PRECEDING) {
org.teiid.language.WindowFunction translate(WindowFunction windowFunction) { org.teiid.language.WindowFunction result = new org.teiid.language.WindowFunction(); result.setFunction(translate(windowFunction.getFunction())); WindowSpecification ws = new WindowSpecification(); ws.setOrderBy(translate(windowFunction.getWindowSpecification().getOrderBy(), false)); List<Expression> partition = windowFunction.getWindowSpecification().getPartition(); if (partition != null) { ArrayList<org.teiid.language.Expression> partitionList = translateExpressionList(partition); ws.setPartition(partitionList); } WindowFrame frame = windowFunction.getWindowSpecification().getWindowFrame(); if (frame != null) { org.teiid.language.WindowFrame resultFrame = new org.teiid.language.WindowFrame(frame.getMode()); resultFrame.setStart(translate(frame.getStart())); resultFrame.setEnd(translate(frame.getEnd())); ws.setWindowFrame(resultFrame); } result.setWindowSpecification(ws); return result; }
org.teiid.language.WindowFunction translate(WindowFunction windowFunction) { org.teiid.language.WindowFunction result = new org.teiid.language.WindowFunction(); result.setFunction(translate(windowFunction.getFunction())); WindowSpecification ws = new WindowSpecification(); ws.setOrderBy(translate(windowFunction.getWindowSpecification().getOrderBy(), false)); List<Expression> partition = windowFunction.getWindowSpecification().getPartition(); if (partition != null) { ArrayList<org.teiid.language.Expression> partitionList = translateExpressionList(partition); ws.setPartition(partitionList); } WindowFrame frame = windowFunction.getWindowSpecification().getWindowFrame(); if (frame != null) { org.teiid.language.WindowFrame resultFrame = new org.teiid.language.WindowFrame(frame.getMode()); resultFrame.setStart(translate(frame.getStart())); resultFrame.setEnd(translate(frame.getEnd())); ws.setWindowFrame(resultFrame); } result.setWindowSpecification(ws); return result; }
FrameBound start = frame.getStart(); FrameBound end = frame.getEnd(); if (start.getBoundMode() == BoundMode.FOLLOWING && (start.getBound() == null || end == null)) {
FrameBound start = frame.getStart(); FrameBound end = frame.getEnd(); if (start.getBoundMode() == BoundMode.FOLLOWING && (start.getBound() == null || end == null)) {