diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPruner.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPruner.java index 7e39d77..d59603e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPruner.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ColumnPruner.java @@ -158,14 +158,15 @@ protected void walk(Node nd) throws SemanticException { boolean walkChildren = true; opStack.push(nd); - // no need to go further down for a select op with a file sink or script - // child - // since all cols are needed for these ops + // no need to go further down for a select op with all file sink or script + // child since all cols are needed for these ops + // However, if one of the children is not file sink or script, we still go down. if (nd instanceof SelectOperator) { + walkChildren = false; for (Node child : nd.getChildren()) { - if ((child instanceof FileSinkOperator) - || (child instanceof ScriptOperator)) { - walkChildren = false; + if (!(child instanceof FileSinkOperator || child instanceof ScriptOperator)) { + walkChildren = true; + break; } } } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsAutoGatherContext.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsAutoGatherContext.java index 3b719af..4205287 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsAutoGatherContext.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsAutoGatherContext.java @@ -197,6 +197,12 @@ private void replaceSelectOperatorProcess(SelectOperator operator, Operator