diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPrunerProcCtx.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPrunerProcCtx.java index 2207cfb2efdb4598dc742d3d497146b52ed39fac..6ca45cc628b5323338eac258d16ab1089ec96d59 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPrunerProcCtx.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPrunerProcCtx.java @@ -117,6 +117,10 @@ public ParseContext getParseContext() { } } else { prunList = prunedColLists.get(child); + if((prunList != null && prunList.isEmpty()) && (child instanceof SelectOperator) + && !(curOp instanceof SelectOperator)) { + prunList = getAllColsFromSelect((SelectOperator)child); + } } if (prunList == null) { continue; @@ -164,7 +168,12 @@ public ParseContext getParseContext() { } return prunList; } else { - return prunedColLists.get(child); + List prunList = prunedColLists.get(child); + if((prunList != null && prunList.isEmpty()) && (child instanceof SelectOperator) + && !(curOp instanceof SelectOperator)) { + prunList = getAllColsFromSelect((SelectOperator)child); + } + return prunList; } } @@ -173,19 +182,17 @@ public ParseContext getParseContext() { * select operator. This function is used for the select operator instead of * the genColLists function (which is used by the rest of the operators). * - * @param op - * The select operator. + * @param op The select operator. * @return List of the internal column names. */ public List getColsFromSelectExpr(SelectOperator op) { - List cols = new ArrayList(); + List cols; SelectDesc conf = op.getConf(); if(conf.isSelStarNoCompute()) { - for (ColumnInfo colInfo : op.getSchema().getSignature()) { - cols.add(colInfo.getInternalName()); - } + cols = getAllColsFromSelect(op); } else { + cols = new ArrayList(); List exprList = conf.getColList(); for (ExprNodeDesc expr : exprList) { cols = Utilities.mergeUniqElems(cols, expr.getCols()); @@ -195,6 +202,21 @@ public ParseContext getParseContext() { } /** + * Creates all internal column names from signature in a + * select operator. + * + * @param op The select operator. + * @return List of the internal column names. + */ + public List getAllColsFromSelect(SelectOperator op) { + List cols = new ArrayList(); + for (ColumnInfo colInfo : op.getSchema().getSignature()) { + cols.add(colInfo.getInternalName()); + } + return cols; + } + + /** * Creates the list of internal column names for select * expressions. * * @param op