File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import java.util
2222import java .util .Properties
2323
2424import org .apache .hadoop .conf .Configuration
25- import org .apache .hadoop .hive .ql .udf .generic .GenericUDF
25+ import org .apache .hadoop .hive .ql .udf .generic .{ GenericUDAFAverage , GenericUDF }
2626import org .apache .hadoop .hive .ql .udf .generic .GenericUDF .DeferredObject
2727import org .apache .hadoop .hive .serde2 .objectinspector .primitive .PrimitiveObjectInspectorFactory
2828import org .apache .hadoop .hive .serde2 .objectinspector .{ObjectInspector , ObjectInspectorFactory }
@@ -93,6 +93,15 @@ class HiveUdfSuite extends QueryTest {
9393 sql(" DROP TEMPORARY FUNCTION IF EXISTS testUdf" )
9494 }
9595
96+ test(" SPARK-6409 UDAFAverage test" ) {
97+ sql(s " CREATE TEMPORARY FUNCTION test_avg AS ' ${classOf [GenericUDAFAverage ].getName}' " )
98+ checkAnswer(
99+ sql(" SELECT test_avg(1), test_avg(substr(value,5)) FROM src" ),
100+ Seq (Row (1.0 , 260.182 )))
101+ sql(" DROP TEMPORARY FUNCTION IF EXISTS test_avg" )
102+ TestHive .reset()
103+ }
104+
96105 test(" SPARK-2693 udaf aggregates test" ) {
97106 checkAnswer(sql(" SELECT percentile(key, 1) FROM src LIMIT 1" ),
98107 sql(" SELECT max(key) FROM src" ).collect().toSeq)
You can’t perform that action at this time.
0 commit comments