HIVE-10522 : CBO (Calcite Return Path): fix the wrong needed column names when 
TS is created (Pengcheng Xiong via John Pullokkaran)

Signed-off-by: Ashutosh Chauhan <hashut...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/14c89028
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/14c89028
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/14c89028

Branch: refs/heads/branch-1.2
Commit: 14c89028f03d586d4873b7bb09c411b38c93e1ea
Parents: b1d3dd4
Author: Pengcheng Xiong <pxi...@hortonworks.com>
Authored: Tue Apr 28 15:36:00 2015 -0700
Committer: Ashutosh Chauhan <hashut...@apache.org>
Committed: Wed Apr 29 13:47:19 2015 -0700

----------------------------------------------------------------------
 .../calcite/translator/HiveOpConverter.java     | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/14c89028/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
----------------------------------------------------------------------
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
 
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
index 85d1663..d266f64 100644
--- 
a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
+++ 
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/HiveOpConverter.java
@@ -209,26 +209,26 @@ public class HiveOpConverter {
     String colName;
     ColumnInfo colInfo;
     VirtualColumn vc;
-    Integer posInRHT;
 
-    for (int i = 0; i < neededColIndxsFrmReloptHT.size(); i++) {
-      colName = scanColNames.get(i);
-      posInRHT = neededColIndxsFrmReloptHT.get(i);
-      if (VColsMap.containsKey(posInRHT)) {
-        vc = VColsMap.get(posInRHT);
+    for (int index = 0; index < scanRel.getRowType().getFieldList().size(); 
index++) {
+      colName = scanColNames.get(index);
+      if (VColsMap.containsKey(index)) {
+        vc = VColsMap.get(index);
         virtualCols.add(vc);
         colInfo = new ColumnInfo(vc.getName(), vc.getTypeInfo(), tableAlias, 
true, vc.getIsHidden());
-        vcolsInCalcite.add(posInRHT);
-      } else if (posToPartColInfo.containsKey(posInRHT)) {
+        vcolsInCalcite.add(index);
+      } else if (posToPartColInfo.containsKey(index)) {
         partColNames.add(colName);
-        colInfo = posToPartColInfo.get(posInRHT);
-        vcolsInCalcite.add(posInRHT);
+        colInfo = posToPartColInfo.get(index);
+        vcolsInCalcite.add(index);
       } else {
-        colInfo = posToNonPartColInfo.get(posInRHT);
+        colInfo = posToNonPartColInfo.get(index);
       }
-      neededColumnIDs.add(posInRHT);
-      neededColumnNames.add(colName);
       colInfos.add(colInfo);
+      if (neededColIndxsFrmReloptHT.contains(index)) {
+        neededColumnIDs.add(index);
+        neededColumnNames.add(colName);
+      }
     }
 
     // 1.2 Create TableScanDesc

Reply via email to