hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1673971 - in /hive/branches/cbo/ql/src: java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java test/queries/clientpositive/cbo_simple_select.q test/results/clientpositive/cbo_simple_select.q.out
Date Wed, 15 Apr 2015 22:27:53 GMT
Author: hashutosh
Date: Wed Apr 15 22:27:53 2015
New Revision: 1673971

URL: http://svn.apache.org/r1673971
Log:
HIVE-10344 : CBO (Calcite Return Path): Use newInstance to create ExprNodeGenericFuncDesc
rather than construction function (Pengcheng Xiong via Ashutosh Chauhan)

Modified:
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
    hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_simple_select.q
    hive/branches/cbo/ql/src/test/results/clientpositive/cbo_simple_select.q.out

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java?rev=1673971&r1=1673970&r2=1673971&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
(original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
Wed Apr 15 22:27:53 2015
@@ -39,8 +39,11 @@ import org.apache.calcite.rex.RexWindow;
 import org.apache.calcite.rex.RexWindowBound;
 import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.type.SqlTypeUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.common.type.HiveChar;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
+import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
 import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.Schema;
 import org.apache.hadoop.hive.ql.parse.ASTNode;
 import org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order;
@@ -76,6 +79,7 @@ public class ExprNodeConverter extends R
   boolean            partitioningExpr;
   WindowFunctionSpec wfs;
   private final RelDataTypeFactory dTFactory;
+  protected final Log LOG = LogFactory.getLog(this.getClass().getName());
 
   public ExprNodeConverter(String tabAlias, RelDataType inputRowType,
           boolean partitioningExpr, RelDataTypeFactory dTFactory) {
@@ -128,29 +132,42 @@ public class ExprNodeConverter extends R
             call.operands.get(0).getType())) {
       return args.get(0);
     } else if (ASTConverter.isFlat(call)) {
-        // If Expr is flat (and[p,q,r,s] or[p,q,r,s]) then recursively build the
-        // exprnode
+      // If Expr is flat (and[p,q,r,s] or[p,q,r,s]) then recursively build the
+      // exprnode
+      GenericUDF hiveUdf = SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType(),
2);
       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(), 2), tmpExprArgs);
+      try {
+        gfDesc = ExprNodeGenericFuncDesc.newInstance(hiveUdf, tmpExprArgs);
+      } catch (UDFArgumentException e) {
+        LOG.error(e);
+        throw new RuntimeException(e);
+      }
       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(), 2), tmpExprArgs);
+        try {
+          gfDesc = ExprNodeGenericFuncDesc.newInstance(hiveUdf, tmpExprArgs);
+        } catch (UDFArgumentException e) {
+          LOG.error(e);
+          throw new RuntimeException(e);
+        }
       }
     } else {
-      GenericUDF hiveUdf = SqlFunctionConverter.getHiveUDF(
-          call.getOperator(), call.getType(), args.size());
+      GenericUDF hiveUdf = SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType(),
+          args.size());
       if (hiveUdf == null) {
-        throw new RuntimeException("Cannot find UDF for " + call.getType() + " " + call.getOperator()
-            + "[" + call.getOperator().getKind() + "]/" + args.size());
+        throw new RuntimeException("Cannot find UDF for " + call.getType() + " "
+            + call.getOperator() + "[" + call.getOperator().getKind() + "]/" + args.size());
+      }
+      try {
+        gfDesc = ExprNodeGenericFuncDesc.newInstance(hiveUdf, args);
+      } catch (UDFArgumentException e) {
+        LOG.error(e);
+        throw new RuntimeException(e);
       }
-      gfDesc = new ExprNodeGenericFuncDesc(TypeConverter.convert(call.getType()), hiveUdf,
args);
     }
-
     return gfDesc;
   }
 

Modified: hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_simple_select.q
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_simple_select.q?rev=1673971&r1=1673970&r2=1673971&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_simple_select.q (original)
+++ hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_simple_select.q Wed Apr 15 22:27:53
2015
@@ -9,7 +9,8 @@ select * from cbo_t1;
 select * from cbo_t1 as cbo_t1;
 select * from cbo_t1 as cbo_t2;
 
-select cbo_t1.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1; 
+select cbo_t1.key as x, c_int as c_int, (((c_int+c_float)*10)+5) as y from cbo_t1;
+select * from cbo_t1 where (((key=1) and (c_float=10)) and (c_int=20)); 
 
 -- 2. Test Select + TS + FIL
 select * from cbo_t1 where cbo_t1.c_int >= 0;

Modified: hive/branches/cbo/ql/src/test/results/clientpositive/cbo_simple_select.q.out
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/test/results/clientpositive/cbo_simple_select.q.out?rev=1673971&r1=1673970&r2=1673971&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/test/results/clientpositive/cbo_simple_select.q.out (original)
+++ hive/branches/cbo/ql/src/test/results/clientpositive/cbo_simple_select.q.out Wed Apr 15
22:27:53 2015
@@ -120,6 +120,16 @@ POSTHOOK: Input: default@cbo_t1@dt=2014
 1	1	25.0
 NULL	NULL	NULL
 NULL	NULL	NULL
+PREHOOK: query: select * from cbo_t1 where (((key=1) and (c_float=10)) and (c_int=20))
+PREHOOK: type: QUERY
+PREHOOK: Input: default@cbo_t1
+PREHOOK: Input: default@cbo_t1@dt=2014
+#### A masked pattern was here ####
+POSTHOOK: query: select * from cbo_t1 where (((key=1) and (c_float=10)) and (c_int=20))
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@cbo_t1
+POSTHOOK: Input: default@cbo_t1@dt=2014
+#### A masked pattern was here ####
 PREHOOK: query: -- 2. Test Select + TS + FIL
 select * from cbo_t1 where cbo_t1.c_int >= 0
 PREHOOK: type: QUERY



Mime
View raw message