Integer getWindowEndOffset() { if (windowFrame.getEnd() == null || windowFrame.getEnd().getBoundMode() == BoundMode.CURRENT_ROW) { return 0; } if (windowFrame.getEnd().getBound() == null) { return null; } return (windowFrame.getEnd().getBoundMode() == BoundMode.PRECEDING?-1:1)*windowFrame.getEnd().getBound(); }
Integer getWindowEndOffset() { if (windowFrame.getEnd() == null || windowFrame.getEnd().getBoundMode() == BoundMode.CURRENT_ROW) { return 0; } if (windowFrame.getEnd().getBound() == null) { return null; } return (windowFrame.getEnd().getBoundMode() == BoundMode.PRECEDING?-1:1)*windowFrame.getEnd().getBound(); }
@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()); } }
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)); } }
windowFrame.setStart(new FrameBound(BoundMode.CURRENT_ROW)); if (windowFrame.getEnd() != null && Integer.valueOf(0).equals(windowFrame.getEnd().getBound())) { windowFrame.setEnd(new FrameBound(BoundMode.CURRENT_ROW)); && (windowFrame.getEnd() == null || windowFrame.getEnd().getBoundMode() == BoundMode.CURRENT_ROW) && windowFrame.getStart().getBound() == null && windowFrame.getStart().getBoundMode() == BoundMode.PRECEDING) { if (windowFrame.getEnd() == null || windowFrame.getEnd().getBoundMode() == BoundMode.CURRENT_ROW) {
windowFrame.setStart(new FrameBound(BoundMode.CURRENT_ROW)); if (windowFrame.getEnd() != null && Integer.valueOf(0).equals(windowFrame.getEnd().getBound())) { windowFrame.setEnd(new FrameBound(BoundMode.CURRENT_ROW)); && (windowFrame.getEnd() == null || windowFrame.getEnd().getBoundMode() == BoundMode.CURRENT_ROW) && windowFrame.getStart().getBound() == null && windowFrame.getStart().getBoundMode() == BoundMode.PRECEDING) { if (windowFrame.getEnd() == null || windowFrame.getEnd().getBoundMode() == BoundMode.CURRENT_ROW) {
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 end = frame.getEnd(); if (start.getBoundMode() == BoundMode.FOLLOWING && (start.getBound() == null || end == null)) { handleValidationError(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31283, new Object[] {windowFunction}), windowFunction);
FrameBound end = frame.getEnd(); if (start.getBoundMode() == BoundMode.FOLLOWING && (start.getBound() == null || end == null)) { handleValidationError(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31283, new Object[] {windowFunction}), windowFunction);