Search in sources :

Example 6 with ExprNodeEvaluator

use of org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator in project hive by apache.

the class PTFDeserializer method initialize.

protected void initialize(PTFExpressionDef eDef, ShapeDetails inpShape) throws HiveException {
    ExprNodeDesc exprNode = eDef.getExprNode();
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(llInfo, exprNode);
    ObjectInspector oi = initExprNodeEvaluator(exprEval, exprNode, inpShape);
    eDef.setExprEvaluator(exprEval);
    eDef.setOI(oi);
}
Also used : ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)

Example 7 with ExprNodeEvaluator

use of org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator 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)

Example 8 with ExprNodeEvaluator

use of org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator in project SQLWindowing by hbutani.

the class WindowSpecTranslation method translateColumn.

static void translateColumn(QueryDef qDef, ColumnDef cDef, InputInfo iInfo, ColumnSpec cSpec) throws WindowingException {
    String colTabName = cSpec.getTableName();
    if (colTabName != null && !colTabName.equals(iInfo.getAlias())) {
        throw new WindowingException(sprintf("Unknown Table Reference in column", cSpec));
    }
    ASTNode expr = TranslateUtils.buildASTNode(cSpec.getColumnName());
    ExprNodeDesc exprNode = TranslateUtils.buildExprNode(expr, iInfo.getTypeCheckCtx());
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(qDef.getTranslationInfo(), exprNode);
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
    cDef.setExpression(expr);
    cDef.setExprNode(exprNode);
    cDef.setExprEvaluator(exprEval);
    cDef.setOI(oi);
    cDef.setAlias(cSpec.getColumnName());
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) WindowingException(com.sap.hadoop.windowing.WindowingException) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc)

Example 9 with ExprNodeEvaluator

use of org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator in project SQLWindowing by hbutani.

the class QueryDefDeserializer method visit.

/*
	 * Recreate the ExprEvaluator, OI using the current inputInfo This is the
	 * inputInfo on the first InputDef in chain if the query does not have a map
	 * phase; else it is the mapInputInfo on the table function definition
	 */
@Override
public void visit(ArgDef arg) throws WindowingException {
    ExprNodeDesc exprNodeDesc = arg.getExprNode();
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(tInfo, exprNodeDesc);
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNodeDesc, exprEval, inputInfo);
    arg.setExprEvaluator(exprEval);
    arg.setOI(oi);
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc)

Example 10 with ExprNodeEvaluator

use of org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator in project SQLWindowing by hbutani.

the class QueryDefDeserializer method visit.

/*
	 * Recreate ExprNodeEvaluator, OI using InputInfo of first InputDef in
	 * chain.
	 */
@Override
public void visit(ColumnDef column) throws WindowingException {
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(tInfo, column.getExprNode());
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, column.getExprNode(), exprEval, inputInfo);
    column.setExprEvaluator(exprEval);
    column.setOI(oi);
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)

Aggregations

ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)30 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)27 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)18 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)13 ArrayList (java.util.ArrayList)10 WindowingException (com.sap.hadoop.windowing.WindowingException)8 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)8 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)7 ColumnDef (com.sap.hadoop.windowing.query2.definition.ColumnDef)3 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)3 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)3 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)3 WhereDef (com.sap.hadoop.windowing.query2.definition.WhereDef)2 List (java.util.List)2 VectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression)2 VectorExpressionWriter (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriter)2 VectorExpressionWriterFactory (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpressionWriterFactory)2 Converter (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 GenericUDFLeadLag (com.sap.hadoop.windowing.functions2.GenericUDFLeadLag)1