diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/Optimizer.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/Optimizer.java index 7b4c306..4ee4bdc 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/Optimizer.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/Optimizer.java @@ -64,10 +64,10 @@ public void initialize(HiveConf hiveConf) { // Add the transformation that computes the lineage information. transformations.add(new Generator()); if (HiveConf.getBoolVar(hiveConf, HiveConf.ConfVars.HIVEOPTPPD)) { - transformations.add(new PredicateTransitivePropagate()); - if (HiveConf.getBoolVar(hiveConf, HiveConf.ConfVars.HIVEOPTCONSTANTPROPAGATION)) { - transformations.add(new ConstantPropagate()); - } + transformations.add(new PredicateTransitivePropagate()); + if (HiveConf.getBoolVar(hiveConf, HiveConf.ConfVars.HIVEOPTCONSTANTPROPAGATION)) { + transformations.add(new ConstantPropagate()); + } transformations.add(new SyntheticJoinPredicate()); transformations.add(new PredicatePushDown()); } diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java index 9e8b362..d15520c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java @@ -261,12 +261,16 @@ OpAttr visit(HiveProject projectRel) throws SemanticException { } WindowingSpec windowingSpec = new WindowingSpec(); + List exprNames = new ArrayList(projectRel.getRowType().getFieldNames()); List exprCols = new ArrayList(); + Map colExprMap = new HashMap(); for (int pos = 0; pos < projectRel.getChildExps().size(); pos++) { ExprNodeConverter converter = new ExprNodeConverter(inputOpAf.tabAlias, projectRel .getRowType().getFieldNames().get(pos), projectRel.getInput().getRowType(), projectRel.getRowType(), false, projectRel.getCluster().getTypeFactory()); - exprCols.add(projectRel.getChildExps().get(pos).accept(converter)); + ExprNodeDesc exprCol = projectRel.getChildExps().get(pos).accept(converter); + colExprMap.put(exprNames.get(pos), exprCol); + exprCols.add(exprCol); if (converter.getWindowFunctionSpec() != null) { windowingSpec.addWindowFunction(converter.getWindowFunctionSpec()); } @@ -276,12 +280,12 @@ OpAttr visit(HiveProject projectRel) throws SemanticException { inputOpAf = genPTF(inputOpAf, windowingSpec); } // TODO: is this a safe assumption (name collision, external names...) - List exprNames = new ArrayList(projectRel.getRowType().getFieldNames()); SelectDesc sd = new SelectDesc(exprCols, exprNames); Pair, Map> colInfoVColPair = createColInfos( projectRel.getChildExps(), exprCols, exprNames, inputOpAf); SelectOperator selOp = (SelectOperator) OperatorFactory.getAndMakeChild(sd, new RowSchema( colInfoVColPair.getKey()), inputOpAf.inputs.get(0)); + selOp.setColumnExprMap(colExprMap); if (LOG.isDebugEnabled()) { LOG.debug("Generated " + selOp + " with row schema: [" + selOp.getSchema() + "]");