Search in sources :

Example 1 with OrderDef

use of org.apache.hadoop.hive.ql.plan.ptf.OrderDef in project hive by apache.

the class MultiValueBoundaryScanner method getScanner.

public static ValueBoundaryScanner getScanner(WindowFrameDef winFrameDef) throws HiveException {
    OrderDef orderDef = winFrameDef.getOrderDef();
    int numOrders = orderDef.getExpressions().size();
    if (numOrders != 1) {
        return new MultiValueBoundaryScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef);
    } else {
        return SingleValueBoundaryScanner.getScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef);
    }
}
Also used : OrderDef(org.apache.hadoop.hive.ql.plan.ptf.OrderDef)

Example 2 with OrderDef

use of org.apache.hadoop.hive.ql.plan.ptf.OrderDef in project hive by apache.

the class PTFTranslator method buildOrderExpressions.

/**
 * Collect order expressions for RANGE based windowing
 * @throws SemanticException
 */
private OrderDef buildOrderExpressions(ShapeDetails inpShape, List<OrderExpression> orderExpressions) throws SemanticException {
    OrderDef orderDef = new OrderDef();
    for (OrderExpression oe : orderExpressions) {
        PTFTranslator.validateNoLeadLagInValueBoundarySpec(oe.getExpression());
        PTFExpressionDef exprDef = null;
        try {
            exprDef = buildExpressionDef(inpShape, oe.getExpression());
        } catch (HiveException he) {
            throw new SemanticException(he);
        }
        PTFTranslator.validateValueBoundaryExprType(exprDef.getOI());
        OrderExpressionDef orderExprDef = new OrderExpressionDef(exprDef);
        orderExprDef.setOrder(oe.getOrder());
        orderExprDef.setNullOrder(oe.getNullOrder());
        orderDef.addExpression(orderExprDef);
    }
    return orderDef;
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) OrderExpression(org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderExpression) PTFExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef) OrderDef(org.apache.hadoop.hive.ql.plan.ptf.OrderDef) OrderExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)

Example 3 with OrderDef

use of org.apache.hadoop.hive.ql.plan.ptf.OrderDef in project hive by apache.

the class PTFTranslator method translatePartitioning.

private void translatePartitioning(PartitionedTableFunctionDef def, PartitionedTableFunctionSpec spec) throws SemanticException {
    applyConstantPartition(spec);
    if (spec.getPartition() == null) {
        return;
    }
    PartitionDef partDef = translate(def.getRawInputShape(), spec.getPartition());
    OrderDef orderDef = translate(def.getRawInputShape(), spec.getOrder(), partDef);
    def.setPartition(partDef);
    def.setOrder(orderDef);
}
Also used : PartitionDef(org.apache.hadoop.hive.ql.plan.ptf.PartitionDef) OrderDef(org.apache.hadoop.hive.ql.plan.ptf.OrderDef)

Example 4 with OrderDef

use of org.apache.hadoop.hive.ql.plan.ptf.OrderDef in project hive by apache.

the class MultiValueBoundaryScanner method getScanner.

public static ValueBoundaryScanner getScanner(WindowFrameDef winFrameDef, boolean nullsLast) throws HiveException {
    OrderDef orderDef = winFrameDef.getOrderDef();
    int numOrders = orderDef.getExpressions().size();
    if (numOrders != 1) {
        return MultiValueBoundaryScanner.getScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef, nullsLast);
    } else {
        return SingleValueBoundaryScanner.getScanner(winFrameDef.getStart(), winFrameDef.getEnd(), orderDef, nullsLast);
    }
}
Also used : OrderDef(org.apache.hadoop.hive.ql.plan.ptf.OrderDef)

Example 5 with OrderDef

use of org.apache.hadoop.hive.ql.plan.ptf.OrderDef in project hive by apache.

the class PTFTranslator method translate.

private OrderDef translate(ShapeDetails inpShape, OrderSpec spec, PartitionDef partitionDef) throws SemanticException {
    OrderDef def = new OrderDef();
    if (null == spec) {
        return def;
    }
    for (OrderExpression oExpr : spec.getExpressions()) {
        OrderExpressionDef oexpDef = translate(inpShape, oExpr);
        def.addExpression(oexpDef);
    }
    return def;
}
Also used : OrderExpression(org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderExpression) OrderDef(org.apache.hadoop.hive.ql.plan.ptf.OrderDef) OrderExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)

Aggregations

OrderDef (org.apache.hadoop.hive.ql.plan.ptf.OrderDef)7 OrderExpressionDef (org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)3 OrderExpression (org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderExpression)2 PartitionDef (org.apache.hadoop.hive.ql.plan.ptf.PartitionDef)2 ArrayList (java.util.ArrayList)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 PTFQueryInputSpec (org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PTFQueryInputSpec)1 PartitioningSpec (org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.PartitioningSpec)1 WindowExpressionSpec (org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowExpressionSpec)1 WindowFunctionSpec (org.apache.hadoop.hive.ql.parse.WindowingSpec.WindowFunctionSpec)1 PTFDesc (org.apache.hadoop.hive.ql.plan.PTFDesc)1 PTFExpressionDef (org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef)1 ShapeDetails (org.apache.hadoop.hive.ql.plan.ptf.ShapeDetails)1 WindowFunctionDef (org.apache.hadoop.hive.ql.plan.ptf.WindowFunctionDef)1 WindowTableFunctionDef (org.apache.hadoop.hive.ql.plan.ptf.WindowTableFunctionDef)1 TableFunctionEvaluator (org.apache.hadoop.hive.ql.udf.ptf.TableFunctionEvaluator)1 WindowingTableFunctionResolver (org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.WindowingTableFunctionResolver)1 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)1