hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gunt...@apache.org
Subject svn commit: r1612713 - in /hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator: ASTConverter.java ExprNodeConverter.java
Date Tue, 22 Jul 2014 22:24:59 GMT
Author: gunther
Date: Tue Jul 22 22:24:59 2014
New Revision: 1612713

URL: http://svn.apache.org/r1612713
Log:
HIVE-7474: Expression Converter needs to handle Flattened expressions (Laljo John Pullokkaran
via Gunther Hagleitner)

Modified:
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ASTConverter.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ExprNodeConverter.java

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ASTConverter.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ASTConverter.java?rev=1612713&r1=1612712&r2=1612713&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ASTConverter.java
(original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ASTConverter.java
Tue Jul 22 22:24:59 2014
@@ -423,7 +423,7 @@ public class ASTConverter {
     }
   }
 
-  private static boolean isFlat(RexCall call) {
+  public static boolean isFlat(RexCall call) {
     boolean flat = false;
     if (call.operands != null && call.operands.size() > 2) {
       SqlOperator op = call.getOperator();

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ExprNodeConverter.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ExprNodeConverter.java?rev=1612713&r1=1612712&r2=1612713&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ExprNodeConverter.java
(original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/ExprNodeConverter.java
Tue Jul 22 22:24:59 2014
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.ql.optimizer.optiq.translator;
 
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -26,6 +27,7 @@ import org.apache.hadoop.hive.ql.plan.Ex
 import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
 import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
 import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.eigenbase.reltype.RelDataType;
 import org.eigenbase.reltype.RelDataTypeField;
@@ -68,6 +70,8 @@ public class ExprNodeConverter extends R
 
   @Override
   public ExprNodeDesc visitCall(RexCall call) {
+    ExprNodeGenericFuncDesc gfDesc = null;
+    
     if (!deep) {
       return null;
     }
@@ -78,8 +82,26 @@ public class ExprNodeConverter extends R
       args.add(operand.accept(this));
     }
 
-    return new ExprNodeGenericFuncDesc(TypeConverter.convert(call.getType()),
-        SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType()), args);
+    // If Expr is flat (and[p,q,r,s] or[p,q,r,s]) then recursively build the
+    // exprnode
+    if (ASTConverter.isFlat(call)) {
+      ArrayList<ExprNodeDesc> tmpExprArgs = new ArrayList<ExprNodeDesc>();
+      tmpExprArgs.addAll(args.subList(0, 2));
+      gfDesc = new ExprNodeGenericFuncDesc(TypeConverter.convert(call.getType()),
+          SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType()), tmpExprArgs);
+      for (int i = 2; i < call.operands.size(); i++) {
+        tmpExprArgs = new ArrayList<ExprNodeDesc>();
+        tmpExprArgs.add(gfDesc);
+        tmpExprArgs.add(args.get(i));
+        gfDesc = new ExprNodeGenericFuncDesc(TypeConverter.convert(call.getType()),
+            SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType()), tmpExprArgs);
+      }
+    } else {
+      gfDesc = new ExprNodeGenericFuncDesc(TypeConverter.convert(call.getType()),
+          SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType()), args);
+    }
+
+    return gfDesc;
   }
 
   @Override



Mime
View raw message