Search in sources :

Example 1 with HiveOpConverter

use of org.apache.hadoop.hive.ql.optimizer.calcite.translator.HiveOpConverter in project hive by apache.

the class CalcitePlanner method getOptimizedHiveOPDag.

/**
   * Get Optimized Hive Operator DAG for the given QB tree in the semAnalyzer.
   *
   * @return Optimized Hive operator tree
   * @throws SemanticException
   */
Operator getOptimizedHiveOPDag() throws SemanticException {
    RelNode optimizedOptiqPlan = null;
    CalcitePlannerAction calcitePlannerAction = null;
    if (this.columnAccessInfo == null) {
        this.columnAccessInfo = new ColumnAccessInfo();
    }
    calcitePlannerAction = new CalcitePlannerAction(prunedPartitions, this.columnAccessInfo);
    try {
        optimizedOptiqPlan = Frameworks.withPlanner(calcitePlannerAction, Frameworks.newConfigBuilder().typeSystem(new HiveTypeSystemImpl()).build());
    } catch (Exception e) {
        rethrowCalciteException(e);
        throw new AssertionError("rethrowCalciteException didn't throw for " + e.getMessage());
    }
    RelNode modifiedOptimizedOptiqPlan = PlanModifierForReturnPath.convertOpTree(optimizedOptiqPlan, resultSchema, this.getQB().getTableDesc() != null);
    LOG.debug("Translating the following plan:\n" + RelOptUtil.toString(modifiedOptimizedOptiqPlan));
    Operator<?> hiveRoot = new HiveOpConverter(this, conf, unparseTranslator, topOps).convert(modifiedOptimizedOptiqPlan);
    RowResolver hiveRootRR = genRowResolver(hiveRoot, getQB());
    opParseCtx.put(hiveRoot, new OpParseContext(hiveRootRR));
    String dest = getQB().getParseInfo().getClauseNames().iterator().next();
    if (getQB().getParseInfo().getDestSchemaForClause(dest) != null && this.getQB().getTableDesc() == null) {
        Operator<?> selOp = handleInsertStatement(dest, hiveRoot, hiveRootRR, getQB());
        return genFileSinkPlan(dest, getQB(), selOp);
    } else {
        return genFileSinkPlan(dest, getQB(), hiveRoot);
    }
}
Also used : HiveRelNode(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode) RelNode(org.apache.calcite.rel.RelNode) HiveOpConverter(org.apache.hadoop.hive.ql.optimizer.calcite.translator.HiveOpConverter) CalciteSubquerySemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException) IOException(java.io.IOException) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException) CalciteViewSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteViewSemanticException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) InvocationTargetException(java.lang.reflect.InvocationTargetException) HiveTypeSystemImpl(org.apache.hadoop.hive.ql.optimizer.calcite.HiveTypeSystemImpl)

Aggregations

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 RelNode (org.apache.calcite.rel.RelNode)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)1 CalciteSubquerySemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException)1 CalciteViewSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteViewSemanticException)1 HiveTypeSystemImpl (org.apache.hadoop.hive.ql.optimizer.calcite.HiveTypeSystemImpl)1 HiveRelNode (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode)1 HiveOpConverter (org.apache.hadoop.hive.ql.optimizer.calcite.translator.HiveOpConverter)1