use of com.sap.hadoop.windowing.query2.definition.WindowFrameDef.RangeBoundaryDef in project SQLWindowing by hbutani.
the class WindowSpecTranslation method translateBoundary.
static BoundaryDef translateBoundary(QueryDef qDef, BoundarySpec bndSpec, InputInfo iInfo) throws WindowingException {
if (bndSpec instanceof ValueBoundarySpec) {
ValueBoundarySpec vBndSpec = (ValueBoundarySpec) bndSpec;
ValueBoundaryDef vbDef = new ValueBoundaryDef(vBndSpec);
TranslateUtils.validateNoLeadLagInValueBoundarySpec(vBndSpec.getExpression());
ExprNodeDesc exprNode = TranslateUtils.buildExprNode(vBndSpec.getExpression(), iInfo.getTypeCheckCtx());
vbDef.setExprNode(exprNode);
ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(qDef.getTranslationInfo(), exprNode);
ObjectInspector OI = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
TranslateUtils.validateValueBoundaryExprType(OI);
vbDef.setExprEvaluator(exprEval);
vbDef.setOI(OI);
return vbDef;
} else if (bndSpec instanceof RangeBoundarySpec) {
RangeBoundarySpec rBndSpec = (RangeBoundarySpec) bndSpec;
RangeBoundaryDef rbDef = new RangeBoundaryDef(rBndSpec);
return rbDef;
} else if (bndSpec instanceof CurrentRowSpec) {
CurrentRowSpec cBndSpec = (CurrentRowSpec) bndSpec;
CurrentRowDef cbDef = new CurrentRowDef(cBndSpec);
return cbDef;
}
throw new WindowingException("Unknown Boundary: " + bndSpec);
}
use of com.sap.hadoop.windowing.query2.definition.WindowFrameDef.RangeBoundaryDef in project SQLWindowing by hbutani.
the class LocalExecutorTests method testWindowClause.
@Test
public void testWindowClause() throws WindowingException {
QueryDef qDef = wshell.translate("select p_mfgr,p_name, p_size, " + "sum(p_size) over w1 as s, " + " denserank() as dr " + " from part_demo " + " partition by p_mfgr" + " window w1 as rows between 2 preceding and 2 following" + " into path='/tmp/wout2'" + " serde 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'" + " with serdeproperties('field.delim'=',')" + " format 'org.apache.hadoop.mapred.TextOutputFormat'");
RangeBoundaryDef rBdef = (RangeBoundaryDef) qDef.getSelectList().getWindowFuncs().get(0).getWindow().getWindow().getStart();
assert rBdef.getAmt() == 2;
rBdef = (RangeBoundaryDef) qDef.getSelectList().getWindowFuncs().get(0).getWindow().getWindow().getEnd();
assert rBdef.getAmt() == 2;
}
Aggregations