Search in sources :

Example 1 with GenericUDFLeadLag

use of com.sap.hadoop.windowing.functions2.GenericUDFLeadLag in project SQLWindowing by hbutani.

the class RuntimeUtils method connectLeadLagFunctionsToPartition.

public static void connectLeadLagFunctionsToPartition(QueryDef qDef, PartitionIterator<Object> pItr) throws WindowingException {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    List<ExprNodeGenericFuncDesc> llFnDescs = tInfo.getLLInfo().getLeadLagExprs();
    if (llFnDescs == null)
        return;
    for (ExprNodeGenericFuncDesc llFnDesc : llFnDescs) {
        GenericUDFLeadLag llFn = (GenericUDFLeadLag) llFnDesc.getGenericUDF();
        llFn.setpItr(pItr);
    }
}
Also used : GenericUDFLeadLag(com.sap.hadoop.windowing.functions2.GenericUDFLeadLag) ExprNodeGenericFuncDesc(org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc) QueryTranslationInfo(com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo)

Example 2 with GenericUDFLeadLag

use of com.sap.hadoop.windowing.functions2.GenericUDFLeadLag in project SQLWindowing by hbutani.

the class TranslateUtils method initExprNodeEvaluator.

public static ObjectInspector initExprNodeEvaluator(QueryDef qDef, ExprNodeDesc exprNode, ExprNodeEvaluator exprEval, InputInfo iInfo) throws WindowingException {
    ObjectInspector OI;
    try {
        OI = exprEval.initialize(iInfo.getOI());
    } catch (HiveException he) {
        throw new WindowingException(he);
    }
    /*
		 * if there are any LeadLag functions in this Expression Tree: - setup a
		 * duplicate Evaluator for the 1st arg of the LLFuncDesc - initialize it
		 * using the InputInfo provided for this Expr tree - set the duplicate
		 * evaluator on the LLUDF instance.
		 */
    LeadLagInfo llInfo = qDef.getTranslationInfo().getLLInfo();
    List<ExprNodeGenericFuncDesc> llFuncExprs = llInfo.getLLFuncExprsInTopExpr(exprNode);
    if (llFuncExprs != null) {
        for (ExprNodeGenericFuncDesc llFuncExpr : llFuncExprs) {
            ExprNodeDesc firstArg = llFuncExpr.getChildren().get(0);
            ExprNodeEvaluator dupExprEval = WindowingExprNodeEvaluatorFactory.get(qDef.getTranslationInfo(), firstArg);
            try {
                dupExprEval.initialize(iInfo.getOI());
            } catch (HiveException he) {
                throw new WindowingException(he);
            }
            GenericUDFLeadLag llFn = (GenericUDFLeadLag) llFuncExpr.getGenericUDF();
            llFn.setExprEvaluator(dupExprEval);
        }
    }
    return OI;
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector) PrimitiveObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) LeadLagInfo(com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.LeadLagInfo) GenericUDFLeadLag(com.sap.hadoop.windowing.functions2.GenericUDFLeadLag) WindowingException(com.sap.hadoop.windowing.WindowingException) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) ExprNodeGenericFuncDesc(org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc)

Aggregations

GenericUDFLeadLag (com.sap.hadoop.windowing.functions2.GenericUDFLeadLag)2 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)2 WindowingException (com.sap.hadoop.windowing.WindowingException)1 QueryTranslationInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo)1 LeadLagInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.LeadLagInfo)1 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)1 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)1