private WindowSpec processWindowSpec(ASTNode node) throws SemanticException {
String sourceId = null;
PartitionSpec partition = null;
OrderSpec order = null;
WindowFrameSpec windowFrame = null;
boolean hasSrcId = false, hasPartSpec = false, hasWF = false;
int srcIdIdx = -1, partIdx = -1, wfIdx = -1;
for(int i=0; i < node.getChildCount(); i++)
{
int type = node.getChild(i).getType();
switch(type)
{
case HiveParser.Identifier:
hasSrcId = true; srcIdIdx = i;
break;
case HiveParser.TOK_PARTITIONINGSPEC:
hasPartSpec = true; partIdx = i;
break;
case HiveParser.TOK_WINDOWRANGE:
case HiveParser.TOK_WINDOWVALUES:
hasWF = true; wfIdx = i;
break;
}
}
WindowSpec ws = new WindowSpec();
if (hasSrcId) {
ASTNode nameNode = (ASTNode) node.getChild(srcIdIdx);
ws.setSourceId(nameNode.getText());
}
if (hasPartSpec) {
ASTNode partNode = (ASTNode) node.getChild(partIdx);
PartitioningSpec partitioning = processPTFPartitionSpec(partNode);
ws.setPartitioning(partitioning);
}
if ( hasWF)
{
ASTNode wfNode = (ASTNode) node.getChild(wfIdx);
WindowFrameSpec wfSpec = processWindowFrame(wfNode);
ws.setWindowFrame(wfSpec);
}
return ws;
}