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;
}
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()));
}
Aggregations