Search in sources :

Example 6 with OrderExpressionDef

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

the class PTFTranslator method translate.

private OrderExpressionDef translate(ShapeDetails inpShape, OrderExpression oExpr) throws SemanticException {
    OrderExpressionDef oexpDef = new OrderExpressionDef();
    oexpDef.setOrder(oExpr.getOrder());
    oexpDef.setNullOrder(oExpr.getNullOrder());
    try {
        PTFExpressionDef expDef = buildExpressionDef(inpShape, oExpr.getExpression());
        oexpDef.setExpressionTreeString(expDef.getExpressionTreeString());
        oexpDef.setExprEvaluator(expDef.getExprEvaluator());
        oexpDef.setExprNode(expDef.getExprNode());
        oexpDef.setOI(expDef.getOI());
    } catch (HiveException he) {
        throw new SemanticException(he);
    }
    PTFTranslator.validateComparable(oexpDef.getOI(), String.format("Partition Expression %s is not a comparable expression", oExpr.getExpression().toStringTree()));
    return oexpDef;
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) PTFExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef) OrderExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)

Example 7 with OrderExpressionDef

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

the class MultiValueBoundaryScanner method getScanner.

@SuppressWarnings("incomplete-switch")
public static SingleValueBoundaryScanner getScanner(BoundaryDef start, BoundaryDef end, OrderDef orderDef) throws HiveException {
    if (orderDef.getExpressions().size() != 1) {
        throw new HiveException("Internal error: initializing SingleValueBoundaryScanner with" + " multiple expression for sorting");
    }
    OrderExpressionDef exprDef = orderDef.getExpressions().get(0);
    PrimitiveObjectInspector pOI = (PrimitiveObjectInspector) exprDef.getOI();
    switch(pOI.getPrimitiveCategory()) {
        case BYTE:
        case INT:
        case LONG:
        case SHORT:
            return new LongValueBoundaryScanner(start, end, exprDef);
        case TIMESTAMP:
            return new TimestampValueBoundaryScanner(start, end, exprDef);
        case TIMESTAMPLOCALTZ:
            return new TimestampLocalTZValueBoundaryScanner(start, end, exprDef);
        case DOUBLE:
        case FLOAT:
            return new DoubleValueBoundaryScanner(start, end, exprDef);
        case DECIMAL:
            return new HiveDecimalValueBoundaryScanner(start, end, exprDef);
        case DATE:
            return new DateValueBoundaryScanner(start, end, exprDef);
        case STRING:
            return new StringValueBoundaryScanner(start, end, exprDef);
    }
    throw new HiveException(String.format("Internal Error: attempt to setup a Window for datatype %s", pOI.getPrimitiveCategory()));
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) OrderExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)

Aggregations

OrderExpressionDef (org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)7 PTFExpressionDef (org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef)4 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 OrderDef (org.apache.hadoop.hive.ql.plan.ptf.OrderDef)3 OrderExpression (org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.OrderExpression)2 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)1 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)1 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)1 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)1 CheckConstraint (org.apache.hadoop.hive.ql.metadata.CheckConstraint)1 DefaultConstraint (org.apache.hadoop.hive.ql.metadata.DefaultConstraint)1 NotNullConstraint (org.apache.hadoop.hive.ql.metadata.NotNullConstraint)1 ExprNodeDescEqualityWrapper (org.apache.hadoop.hive.ql.plan.ExprNodeDesc.ExprNodeDescEqualityWrapper)1 PartitionedTableFunctionDef (org.apache.hadoop.hive.ql.plan.ptf.PartitionedTableFunctionDef)1 WindowFrameDef (org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef)1 WindowFunctionDef (org.apache.hadoop.hive.ql.plan.ptf.WindowFunctionDef)1 WindowTableFunctionDef (org.apache.hadoop.hive.ql.plan.ptf.WindowTableFunctionDef)1