Search in sources :

Example 1 with HiveTypeSystemImpl

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

the class CalcitePlanner method logicalPlan.

/**
   * Get optimized logical plan for the given QB tree in the semAnalyzer.
   *
   * @return
   * @throws SemanticException
   */
RelNode logicalPlan() 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());
    }
    return optimizedOptiqPlan;
}
Also used : HiveRelNode(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode) RelNode(org.apache.calcite.rel.RelNode) 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)

Example 2 with HiveTypeSystemImpl

use of org.apache.hadoop.hive.ql.optimizer.calcite.HiveTypeSystemImpl 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)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 RelNode (org.apache.calcite.rel.RelNode)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)2 CalciteSubquerySemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSubquerySemanticException)2 CalciteViewSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteViewSemanticException)2 HiveTypeSystemImpl (org.apache.hadoop.hive.ql.optimizer.calcite.HiveTypeSystemImpl)2 HiveRelNode (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode)2 HiveOpConverter (org.apache.hadoop.hive.ql.optimizer.calcite.translator.HiveOpConverter)1