public static WindowFrameDef wdwFrame(int p, int f) { BoundaryDef start, end; if (p == 0) { start = new BoundaryDef(Direction.CURRENT, 0); } else { start = new BoundaryDef(Direction.PRECEDING, p); } if (f == 0) { end = new BoundaryDef(Direction.CURRENT, 0); } else { end = new BoundaryDef(Direction.FOLLOWING, f); } return new WindowFrameDef(WindowType.ROWS, start, end); }
private WindowFrameDef translate(ShapeDetails inpShape, WindowFrameSpec spec, List<OrderExpression> orderExpressions) throws SemanticException { if (spec == null) { return null; } BoundarySpec s = spec.getStart(); BoundarySpec e = spec.getEnd(); int cmp = s.compareTo(e); if (cmp > 0) { throw new SemanticException(String.format( "Window range invalid, start boundary is greater than end boundary: %s", spec)); } WindowFrameDef winFrame = new WindowFrameDef( spec.getWindowType(), new BoundaryDef(s.direction, s.getAmt()), new BoundaryDef(e.direction, e.getAmt())); if (winFrame.getWindowType() == WindowType.RANGE) { winFrame.setOrderDef(buildOrderExpressions(inpShape, orderExpressions)); } return winFrame; }
private WindowFrameDef translate(ShapeDetails inpShape, WindowFrameSpec spec, List<OrderExpression> orderExpressions) throws SemanticException { if (spec == null) { return null; } BoundarySpec s = spec.getStart(); BoundarySpec e = spec.getEnd(); int cmp = s.compareTo(e); if (cmp > 0) { throw new SemanticException(String.format( "Window range invalid, start boundary is greater than end boundary: %s", spec)); } WindowFrameDef winFrame = new WindowFrameDef( spec.getWindowType(), new BoundaryDef(s.direction, s.getAmt()), new BoundaryDef(e.direction, e.getAmt())); if (winFrame.getWindowType() == WindowType.RANGE) { winFrame.setOrderDef(buildOrderExpressions(inpShape, orderExpressions)); } return winFrame; }
private WindowFrameDef translate(ShapeDetails inpShape, WindowFrameSpec spec) throws SemanticException { if (spec == null) { return null; } BoundarySpec s = spec.getStart(); BoundarySpec e = spec.getEnd(); int cmp = s.compareTo(e); if (cmp > 0) { throw new SemanticException(String.format( "Window range invalid, start boundary is greater than end boundary: %s", spec)); } WindowFrameDef wfDef = new WindowFrameDef(); wfDef.setStart(translate(inpShape, s)); wfDef.setEnd(translate(inpShape, e)); return wfDef; }