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..eb5dade69d2eba4ace5639bd7fcc77462e6ee5ab 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 @@ -36,6 +36,7 @@ import org.apache.hadoop.hive.ql.parse.ParseContext; import org.apache.hadoop.hive.ql.parse.SemanticException; import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc; +import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.OperatorDesc; import org.apache.hadoop.hive.ql.plan.SelectDesc; @@ -224,7 +225,11 @@ public ParseContext getParseContext() { for (int i = 0; i < outputColumnNames.size(); i++) { if (colList == null || colList.contains(outputColumnNames.get(i))) { ExprNodeDesc expr = selectExprs.get(i); - cols = Utilities.mergeUniqElems(cols, expr.getCols()); + if (expr instanceof ExprNodeConstantDesc) { + cols.add(outputColumnNames.get(i)); + } else { + cols = Utilities.mergeUniqElems(cols, expr.getCols()); + } } }