hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r798969 - in /hadoop/hive/trunk: CHANGES.txt ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java ql/src/test/queries/clientpositive/create_genericudaf.q ql/src/test/results/clientpositive/create_genericudaf.q.out
Date Wed, 29 Jul 2009 16:25:02 GMT
Author: namit
Date: Wed Jul 29 16:25:01 2009
New Revision: 798969

URL: http://svn.apache.org/viewvc?rev=798969&view=rev
Log:
HIVE-698. Add create temporary function for generic UDAF. 
(Zheng Shao via namit)


Added:
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/create_genericudaf.q
    hadoop/hive/trunk/ql/src/test/results/clientpositive/create_genericudaf.q.out
Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=798969&r1=798968&r2=798969&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Wed Jul 29 16:25:01 2009
@@ -103,6 +103,9 @@
 
     HIVE-656. Add a PMOD (POSITIVE MOD) function. (Scott Chen via zshao)
 
+    HIVE-698. Add create temporary function for generic UDAF. 
+    (Zheng Shao via namit)
+
   IMPROVEMENTS
     HIVE-389. Option to build without ivy (jssarma)
 

Modified: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java?rev=798969&r1=798968&r2=798969&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java (original)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionTask.java Wed Jul
29 16:25:01 2009
@@ -27,7 +27,9 @@
 import org.apache.hadoop.hive.ql.plan.FunctionWork;
 import org.apache.hadoop.hive.ql.plan.createFunctionDesc;
 import org.apache.hadoop.hive.ql.plan.dropFunctionDesc;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.hive.ql.exec.FunctionInfo.OperatorType;
 
@@ -72,7 +74,11 @@
         FunctionRegistry.registerUDAF(createFunctionDesc.getFunctionName(),
                                       (Class<? extends UDAF>) udfClass);
         return 0;
-      } 
+      } else if(GenericUDAFResolver.class.isAssignableFrom(udfClass)) {
+        FunctionRegistry.registerGenericUDAF(createFunctionDesc.getFunctionName(),
+            (GenericUDAFResolver)ReflectionUtils.newInstance(udfClass, null));
+        return 0;
+      }
       return 1;
 
     } catch (ClassNotFoundException e) {

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/create_genericudaf.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/create_genericudaf.q?rev=798969&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/create_genericudaf.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/create_genericudaf.q Wed Jul 29 16:25:01
2009
@@ -0,0 +1,17 @@
+EXPLAIN
+CREATE TEMPORARY FUNCTION test_avg AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage';
+
+CREATE TEMPORARY FUNCTION test_avg AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage';
+
+EXPLAIN
+SELECT
+    test_avg(1),
+    test_avg(substr(value,5))
+FROM src;
+
+SELECT
+    test_avg(1),
+    test_avg(substr(value,5))
+FROM src;
+
+DROP TEMPORARY FUNCTIOn test_avg;

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/create_genericudaf.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/create_genericudaf.q.out?rev=798969&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/create_genericudaf.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/create_genericudaf.q.out Wed Jul
29 16:25:01 2009
@@ -0,0 +1,83 @@
+query: EXPLAIN
+CREATE TEMPORARY FUNCTION test_avg AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage'
+ABSTRACT SYNTAX TREE:
+  (TOK_CREATEFUNCTION test_avg 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage')
+
+STAGE DEPENDENCIES:
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-0
+
+
+query: CREATE TEMPORARY FUNCTION test_avg AS 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage'
+query: EXPLAIN
+SELECT
+    test_avg(1),
+    test_avg(substr(value,5))
+FROM src
+ABSTRACT SYNTAX TREE:
+  (TOK_QUERY (TOK_FROM (TOK_TABREF src)) (TOK_INSERT (TOK_DESTINATION (TOK_DIR TOK_TMP_FILE))
(TOK_SELECT (TOK_SELEXPR (TOK_FUNCTION test_avg 1)) (TOK_SELEXPR (TOK_FUNCTION test_avg (TOK_FUNCTION
substr (TOK_TABLE_OR_COL value) 5))))))
+
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Alias -> Map Operator Tree:
+        src 
+            Select Operator
+              expressions:
+                    expr: value
+                    type: string
+              outputColumnNames: value
+              Group By Operator
+                aggregations:
+                      expr: test_avg(1)
+                      expr: test_avg(substr(value, 5))
+                mode: hash
+                outputColumnNames: _col0, _col1
+                Reduce Output Operator
+                  sort order: 
+                  tag: -1
+                  value expressions:
+                        expr: _col0
+                        type: struct<count:bigint,sum:double>
+                        expr: _col1
+                        type: struct<count:bigint,sum:double>
+      Reduce Operator Tree:
+        Group By Operator
+          aggregations:
+                expr: test_avg(VALUE._col0)
+                expr: test_avg(VALUE._col1)
+          mode: mergepartial
+          outputColumnNames: _col0, _col1
+          Select Operator
+            expressions:
+                  expr: _col0
+                  type: double
+                  expr: _col1
+                  type: double
+            outputColumnNames: _col0, _col1
+            File Output Operator
+              compressed: false
+              GlobalTableId: 0
+              table:
+                  input format: org.apache.hadoop.mapred.TextInputFormat
+                  output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: -1
+
+
+query: SELECT
+    test_avg(1),
+    test_avg(substr(value,5))
+FROM src
+Input: default/src
+Output: file:/data/users/zshao/tools/deploy-trunk-apache-hive/build/ql/tmp/1744650408/10000
+1.0	260.182
+query: DROP TEMPORARY FUNCTIOn test_avg



Mime
View raw message