Search in sources :

Example 11 with QueryTranslationInfo

use of com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo 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)

Aggregations

InputInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo)6 WindowingException (com.sap.hadoop.windowing.WindowingException)4 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)4 QueryInputDef (com.sap.hadoop.windowing.query2.definition.QueryInputDef)3 TableFunctionEvaluator (com.sap.hadoop.windowing.functions2.TableFunctionEvaluator)2 ArgDef (com.sap.hadoop.windowing.query2.definition.ArgDef)2 QueryTranslationInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo)2 GenericUDFLeadLag (com.sap.hadoop.windowing.functions2.GenericUDFLeadLag)1 TableFunctionResolver (com.sap.hadoop.windowing.functions2.TableFunctionResolver)1 WindowingInput (com.sap.hadoop.windowing.io.WindowingInput)1 ColumnDef (com.sap.hadoop.windowing.query2.definition.ColumnDef)1 QueryDef (com.sap.hadoop.windowing.query2.definition.QueryDef)1 QueryOutputDef (com.sap.hadoop.windowing.query2.definition.QueryOutputDef)1 SelectDef (com.sap.hadoop.windowing.query2.definition.SelectDef)1 TableFuncDef (com.sap.hadoop.windowing.query2.definition.TableFuncDef)1 WhereDef (com.sap.hadoop.windowing.query2.definition.WhereDef)1 WindowDef (com.sap.hadoop.windowing.query2.definition.WindowDef)1 WindowFunctionDef (com.sap.hadoop.windowing.query2.definition.WindowFunctionDef)1 HiveTableSpec (com.sap.hadoop.windowing.query2.specification.HiveTableSpec)1 QueryOutputSpec (com.sap.hadoop.windowing.query2.specification.QueryOutputSpec)1