Search in sources :

Example 6 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.

the class WhereTranslation method translate.

public static void translate(QueryDef qDef) throws WindowingException {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QuerySpec spec = qDef.getSpec();
    ASTNode wExpr = spec.getWhereExpr();
    if (wExpr == null)
        return;
    WhereDef whDef = new WhereDef();
    whDef.setExpression(wExpr);
    QueryInputDef iDef = qDef.getInput();
    InputInfo iInfo = tInfo.getInputInfo(iDef);
    ExprNodeDesc exprNode = TranslateUtils.buildExprNode(wExpr, iInfo.getTypeCheckCtx());
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(tInfo, exprNode);
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
    try {
        ObjectInspectorConverters.getConverter(oi, PrimitiveObjectInspectorFactory.javaBooleanObjectInspector);
    } catch (Throwable t) {
        throw new WindowingException("Where Expr must be convertible to a boolean value", t);
    }
    whDef.setExprNode(exprNode);
    whDef.setExprEvaluator(exprEval);
    whDef.setOI(oi);
    qDef.setWhere(whDef);
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) WhereDef(com.sap.hadoop.windowing.query2.definition.WhereDef) InputInfo(com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo) QueryInputDef(com.sap.hadoop.windowing.query2.definition.QueryInputDef) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) ExprNodeEvaluator(org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator) WindowingException(com.sap.hadoop.windowing.WindowingException) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc) QuerySpec(com.sap.hadoop.windowing.query2.specification.QuerySpec)

Example 7 with QuerySpec

use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.

the class WindowSpecTranslation method fillInWindowSpec.

static void fillInWindowSpec(QuerySpec qSpec, String sourceId, WindowSpec destWSpec) throws WindowingException {
    if (sourceId != null) {
        WindowSpec sourceWSpec = qSpec.getWindowSpecs().get(sourceId);
        if (sourceWSpec == null) {
            throw new WindowingException(sprintf("Window Spec %s refers to an unknown source", destWSpec));
        }
        if (destWSpec.getPartition() == null) {
            destWSpec.setPartition(sourceWSpec.getPartition());
        }
        if (destWSpec.getOrder() == null) {
            destWSpec.setOrder(sourceWSpec.getOrder());
        }
        if (destWSpec.getWindow() == null) {
            destWSpec.setWindow(sourceWSpec.getWindow());
        }
        fillInWindowSpec(qSpec, sourceWSpec.getSourceId(), destWSpec);
    }
}
Also used : WindowingException(com.sap.hadoop.windowing.WindowingException) WindowSpec(com.sap.hadoop.windowing.query2.specification.WindowSpec)

Aggregations

QuerySpec (com.sap.hadoop.windowing.query2.specification.QuerySpec)5 WindowingException (com.sap.hadoop.windowing.WindowingException)4 HiveQueryDef (com.sap.hadoop.windowing.query2.definition.HiveQueryDef)2 QueryDef (com.sap.hadoop.windowing.query2.definition.QueryDef)2 HiveTableDef (com.sap.hadoop.windowing.query2.definition.HiveTableDef)1 OrderDef (com.sap.hadoop.windowing.query2.definition.OrderDef)1 PartitionDef (com.sap.hadoop.windowing.query2.definition.PartitionDef)1 QueryInputDef (com.sap.hadoop.windowing.query2.definition.QueryInputDef)1 WhereDef (com.sap.hadoop.windowing.query2.definition.WhereDef)1 WindowDef (com.sap.hadoop.windowing.query2.definition.WindowDef)1 WindowFrameDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef)1 HiveQuerySpec (com.sap.hadoop.windowing.query2.specification.HiveQuerySpec)1 OrderSpec (com.sap.hadoop.windowing.query2.specification.OrderSpec)1 PartitionSpec (com.sap.hadoop.windowing.query2.specification.PartitionSpec)1 WindowFrameSpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec)1 WindowSpec (com.sap.hadoop.windowing.query2.specification.WindowSpec)1 QueryComponentizer (com.sap.hadoop.windowing.query2.translate.QueryComponentizer)1 InputInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 ExprNodeEvaluator (org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator)1