Search in sources :

Example 1 with Direction

use of org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction in project hive by apache.

the class BasePartitionEvaluator method getRowBoundaryEnd.

private static int getRowBoundaryEnd(BoundaryDef b, int currRow, PTFPartition p) throws HiveException {
    Direction d = b.getDirection();
    int amt = b.getAmt();
    switch(d) {
        case PRECEDING:
            if (amt == 0) {
                return currRow + 1;
            }
            return currRow - amt + 1;
        case CURRENT:
            return currRow + 1;
        case FOLLOWING:
            if (amt == BoundarySpec.UNBOUNDED_AMOUNT) {
                return p.size();
            } else {
                return currRow + amt + 1;
            }
    }
    throw new HiveException("Unknown End Boundary Direction: " + d);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) Direction(org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction)

Example 2 with Direction

use of org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction in project hive by apache.

the class BasePartitionEvaluator method getRowBoundaryStart.

private static int getRowBoundaryStart(BoundaryDef b, int currRow) throws HiveException {
    Direction d = b.getDirection();
    int amt = b.getAmt();
    switch(d) {
        case PRECEDING:
            if (amt == BoundarySpec.UNBOUNDED_AMOUNT) {
                return 0;
            } else {
                return currRow - amt;
            }
        case CURRENT:
            return currRow;
        case FOLLOWING:
            return currRow + amt;
    }
    throw new HiveException("Unknown Start Boundary Direction: " + d);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) Direction(org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction)

Example 3 with Direction

use of org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction in project hive by apache.

the class ExprNodeConverter method getWindowBound.

private BoundarySpec getWindowBound(RexWindowBound wb) {
    BoundarySpec boundarySpec;
    if (wb.isCurrentRow()) {
        boundarySpec = new BoundarySpec(Direction.CURRENT);
    } else {
        final Direction direction;
        final int amt;
        if (wb.isPreceding()) {
            direction = Direction.PRECEDING;
        } else {
            direction = Direction.FOLLOWING;
        }
        if (wb.isUnbounded()) {
            amt = BoundarySpec.UNBOUNDED_AMOUNT;
        } else {
            amt = RexLiteral.intValue(wb.getOffset());
        }
        boundarySpec = new BoundarySpec(direction, amt);
    }
    return boundarySpec;
}
Also used : BoundarySpec(org.apache.hadoop.hive.ql.parse.WindowingSpec.BoundarySpec) Direction(org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction)

Aggregations

Direction (org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction)3 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 BoundarySpec (org.apache.hadoop.hive.ql.parse.WindowingSpec.BoundarySpec)1