return new WindowFrameSpec(start, end);
}
private BoundarySpec processBoundary(int frameType, ASTNode node) throws SemanticException {
BoundarySpec bs = frameType == HiveParser.TOK_WINDOWRANGE ?
new RangeBoundarySpec() : new ValueBoundarySpec();
int type = node.getType();
boolean hasAmt = true;
switch(type)
{
case HiveParser.KW_PRECEDING:
bs.setDirection(Direction.PRECEDING);
break;
case HiveParser.KW_FOLLOWING:
bs.setDirection(Direction.FOLLOWING);
break;
case HiveParser.KW_CURRENT:
bs = new CurrentRowSpec();
hasAmt = false;
break;
}
if ( hasAmt )
{
ASTNode amtNode = (ASTNode) node.getChild(0);
if ( amtNode.getType() == HiveParser.KW_UNBOUNDED)
{
bs.setAmt(BoundarySpec.UNBOUNDED_AMOUNT);
}
else
{
int amt = Integer.parseInt(amtNode.getText());
if ( amt < 0 ) {
throw new SemanticException(
"Window Frame Boundary Amount must be a +ve integer, amount provide is: " + amt);
}
bs.setAmt(amt);
}
}
return bs;
}