You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by su...@apache.org on 2015/07/20 22:12:14 UTC
[04/50] [abbrv] hive git commit: HIVE-11206 : CBO (Calcite Return
Path): Join translation should update all ExprNode recursively (Jesus Camacho
Rodriguez via Ashutosh Chauhan)
HIVE-11206 : CBO (Calcite Return Path): Join translation should update all ExprNode recursively (Jesus Camacho Rodriguez via Ashutosh Chauhan)
Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/e6ea691d
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/e6ea691d
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/e6ea691d
Branch: refs/heads/spark
Commit: e6ea691d34b1ee12c335a2023849c5c445bfb660
Parents: 20f2c29
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Fri Jul 10 04:29:00 2015 -0700
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Fri Jul 10 08:46:22 2015 -0700
----------------------------------------------------------------------
.../calcite/translator/HiveOpConverter.java | 51 ++++++++++++--------
1 file changed, 30 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/e6ea691d/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 84c6cc8..86ac4d1 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
@@ -906,22 +906,11 @@ public class HiveOpConverter {
// 3. We populate the filters structure
List<ExprNodeDesc> filtersForInput = new ArrayList<ExprNodeDesc>();
for (ExprNodeDesc expr : filterExpressions[pos]) {
- if (expr instanceof ExprNodeGenericFuncDesc) {
- ExprNodeGenericFuncDesc func = (ExprNodeGenericFuncDesc) expr;
- List<ExprNodeDesc> newChildren = new ArrayList<ExprNodeDesc>();
- for (ExprNodeDesc functionChild : func.getChildren()) {
- if (functionChild instanceof ExprNodeColumnDesc) {
- newChildren.add(colExprMap.get(functionChild.getExprString()));
- } else {
- newChildren.add(functionChild);
- }
- }
- func.setChildren(newChildren);
- filtersForInput.add(expr);
- }
- else {
- filtersForInput.add(expr);
- }
+ // We need to update the exprNode, as currently
+ // they refer to columns in the output of the join;
+ // they should refer to the columns output by the RS
+ updateExprNode(expr, colExprMap);
+ filtersForInput.add(expr);
}
filters.put(tag, filtersForInput);
}
@@ -930,11 +919,6 @@ public class HiveOpConverter {
filters, joinExpressions);
desc.setReversedExprs(reversedExprs);
- // 4. Create and populate filter map
- int[][] filterMap = new int[joinExpressions.length][];
-
- desc.setFilterMap(filterMap);
-
JoinOperator joinOp = (JoinOperator) OperatorFactory.getAndMakeChild(desc, new RowSchema(
outputColumns), childOps);
joinOp.setColumnExprMap(colExprMap);
@@ -947,6 +931,31 @@ public class HiveOpConverter {
return joinOp;
}
+ /*
+ * This method updates the input expr, changing all the
+ * ExprNodeColumnDesc in it to refer to columns given by the
+ * colExprMap.
+ *
+ * For instance, "col_0 = 1" would become "VALUE.col_0 = 1";
+ * the execution engine expects filters in the Join operators
+ * to be expressed that way.
+ */
+ private static void updateExprNode(ExprNodeDesc expr, Map<String, ExprNodeDesc> colExprMap) {
+ if (expr instanceof ExprNodeGenericFuncDesc) {
+ ExprNodeGenericFuncDesc func = (ExprNodeGenericFuncDesc) expr;
+ List<ExprNodeDesc> newChildren = new ArrayList<ExprNodeDesc>();
+ for (ExprNodeDesc functionChild : func.getChildren()) {
+ if (functionChild instanceof ExprNodeColumnDesc) {
+ newChildren.add(colExprMap.get(functionChild.getExprString()));
+ } else {
+ updateExprNode(functionChild, colExprMap);
+ newChildren.add(functionChild);
+ }
+ }
+ func.setChildren(newChildren);
+ }
+ }
+
private static JoinType extractJoinType(HiveJoin join) {
// UNIQUE
if (join.isDistinct()) {