Search in sources :

Example 1 with BoundaryDef

use of com.sap.hadoop.windowing.query2.definition.WindowFrameDef.BoundaryDef in project SQLWindowing by hbutani.

the class WindowingTableFunction method getRange.

static Range getRange(WindowFunctionDef wFnDef, int currRow, Partition p) throws WindowingException {
    BoundaryDef startB = wFnDef.getWindow().getWindow().getStart();
    BoundaryDef endB = wFnDef.getWindow().getWindow().getEnd();
    int start = getIndex(startB, currRow, p, false);
    int end = getIndex(endB, currRow, p, true);
    return new Range(start, end, p);
}
Also used : RangeBoundaryDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef.RangeBoundaryDef) ValueBoundaryDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef.ValueBoundaryDef) BoundaryDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef.BoundaryDef)

Example 2 with BoundaryDef

use of com.sap.hadoop.windowing.query2.definition.WindowFrameDef.BoundaryDef 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);
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ValueBoundarySpec(com.sap.hadoop.windowing.query2.specification.WindowFrameSpec.ValueBoundarySpec) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) WindowingException(com.sap.hadoop.windowing.WindowingException) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc) CurrentRowSpec(com.sap.hadoop.windowing.query2.specification.WindowFrameSpec.CurrentRowSpec) ValueBoundaryDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef.ValueBoundaryDef) RangeBoundaryDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef.RangeBoundaryDef) RangeBoundarySpec(com.sap.hadoop.windowing.query2.specification.WindowFrameSpec.RangeBoundarySpec) CurrentRowDef(com.sap.hadoop.windowing.query2.definition.WindowFrameDef.CurrentRowDef)

Aggregations

RangeBoundaryDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef.RangeBoundaryDef)2 ValueBoundaryDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef.ValueBoundaryDef)2 WindowingException (com.sap.hadoop.windowing.WindowingException)1 BoundaryDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef.BoundaryDef)1 CurrentRowDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef.CurrentRowDef)1 CurrentRowSpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec.CurrentRowSpec)1 RangeBoundarySpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec.RangeBoundarySpec)1 ValueBoundarySpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec.ValueBoundarySpec)1 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)1 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1