You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by px...@apache.org on 2015/08/12 01:40:38 UTC
hive git commit: HIVE-8926:: Projections that only swap input columns
are identified incorrectly as identity projections (Jesus via Ashutosh
Chauhan)
Repository: hive
Updated Branches:
refs/heads/branch-1.0 d3919332a -> fbcef73cc
HIVE-8926:: Projections that only swap input columns are identified incorrectly as identity projections (Jesus via Ashutosh Chauhan)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/fbcef73c
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/fbcef73c
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/fbcef73c
Branch: refs/heads/branch-1.0
Commit: fbcef73ccd0ff740329d5ecaa94c57ad20212a0f
Parents: d391933
Author: Ashutosh Chauhan <ha...@apache.org>
Authored: Sun Nov 23 06:32:09 2014 +0000
Committer: Pengcheng Xiong <px...@apache.org>
Committed: Tue Aug 11 16:40:14 2015 -0700
----------------------------------------------------------------------
.../hadoop/hive/ql/exec/SelectOperator.java | 52 +++++++++++++++++---
1 file changed, 46 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/fbcef73c/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java
index 95d2d76..93017d3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/SelectOperator.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.SelectDesc;
import org.apache.hadoop.hive.ql.plan.api.OperatorType;
@@ -133,22 +134,61 @@ public class SelectOperator extends Operator<SelectDesc> implements Serializable
* @return if it is an identity select operator or not
*/
public boolean isIdentitySelect() {
- //Safety check
+ // Safety check
if(this.getNumParent() != 1) {
return false;
}
- //Select *
- if(this.getConf().isSelStarNoCompute() ||
- this.getConf().isSelectStar()) {
+ if(conf.isSelStarNoCompute()) {
return true;
}
- //Check whether the have the same schema
- if(!OperatorUtils.sameRowSchema(this, this.getParentOperators().get(0))) {
+ // Check whether the have the same schema
+ RowSchema orig = this.getSchema();
+ RowSchema dest = this.getParentOperators().get(0).getSchema();
+ if(orig.getSignature() == null && dest.getSignature() == null) {
+ return true;
+ }
+ if((orig.getSignature() == null && dest.getSignature() != null) ||
+ (orig.getSignature() != null && dest.getSignature() == null) ) {
+ return false;
+ }
+
+ if(orig.getSignature().size() != dest.getSignature().size() ||
+ orig.getSignature().size() != conf.getColList().size()) {
return false;
}
+ for(int i=0; i<orig.getSignature().size(); i++) {
+ ColumnInfo origColumn = orig.getSignature().get(i);
+ ColumnInfo destColumn = dest.getSignature().get(i);
+
+ if(origColumn == null && destColumn == null) {
+ continue;
+ }
+
+ if((origColumn == null && destColumn != null) ||
+ (origColumn != null && destColumn == null) ) {
+ return false;
+ }
+
+ if(!origColumn.equals(destColumn)) {
+ return false;
+ }
+
+ // Now we check if though the schemas are the same,
+ // the operator changes the order of columns in the
+ // output
+ if(!(conf.getColList().get(i) instanceof ExprNodeColumnDesc)) {
+ return false;
+ }
+ ExprNodeColumnDesc col = (ExprNodeColumnDesc) conf.getColList().get(i);
+ if(!col.getColumn().equals(origColumn.getInternalName())) {
+ return false;
+ }
+
+ }
+
return true;
}