Skip to content
Snippets Groups Projects
Commit 968408b3 authored by DoingDone9's avatar DoingDone9 Committed by Michael Armbrust
Browse files

[SPARK-6409][SQL] It is not necessary that avoid old inteface of hive, because...

[SPARK-6409][SQL] It is not necessary that avoid old inteface of hive, because this will make some UDAF can not work.

spark avoid old inteface of hive, then some udaf can not work like "org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage"

Author: DoingDone9 <799203320@qq.com>

Closes #5131 from DoingDone9/udaf and squashes the following commits:

9de08d0 [DoingDone9] Update HiveUdfSuite.scala
49c62dc [DoingDone9] Update hiveUdfs.scala
98b134f [DoingDone9] Merge pull request #5 from apache/master
161cae3 [DoingDone9] Merge pull request #4 from apache/master
c87e8b6 [DoingDone9] Merge pull request #3 from apache/master
cb1852d [DoingDone9] Merge pull request #2 from apache/master
c3f046f [DoingDone9] Merge pull request #1 from apache/master
parent 982952f4
No related branches found
No related tags found
No related merge requests found
...@@ -375,9 +375,8 @@ private[hive] case class HiveUdafFunction( ...@@ -375,9 +375,8 @@ private[hive] case class HiveUdafFunction(
private val returnInspector = function.init(GenericUDAFEvaluator.Mode.COMPLETE, inspectors) private val returnInspector = function.init(GenericUDAFEvaluator.Mode.COMPLETE, inspectors)
// Cast required to avoid type inference selecting a deprecated Hive API.
private val buffer = private val buffer =
function.getNewAggregationBuffer.asInstanceOf[GenericUDAFEvaluator.AbstractAggregationBuffer] function.getNewAggregationBuffer
override def eval(input: Row): Any = unwrap(function.evaluate(buffer), returnInspector) override def eval(input: Row): Any = unwrap(function.evaluate(buffer), returnInspector)
......
...@@ -22,7 +22,7 @@ import java.util ...@@ -22,7 +22,7 @@ import java.util
import java.util.Properties import java.util.Properties
import org.apache.hadoop.conf.Configuration import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF import org.apache.hadoop.hive.ql.udf.generic.{GenericUDAFAverage, GenericUDF}
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory
import org.apache.hadoop.hive.serde2.objectinspector.{ObjectInspector, ObjectInspectorFactory} import org.apache.hadoop.hive.serde2.objectinspector.{ObjectInspector, ObjectInspectorFactory}
...@@ -93,6 +93,15 @@ class HiveUdfSuite extends QueryTest { ...@@ -93,6 +93,15 @@ class HiveUdfSuite extends QueryTest {
sql("DROP TEMPORARY FUNCTION IF EXISTS testUdf") sql("DROP TEMPORARY FUNCTION IF EXISTS testUdf")
} }
test("SPARK-6409 UDAFAverage test") {
sql(s"CREATE TEMPORARY FUNCTION test_avg AS '${classOf[GenericUDAFAverage].getName}'")
checkAnswer(
sql("SELECT test_avg(1), test_avg(substr(value,5)) FROM src"),
Seq(Row(1.0, 260.182)))
sql("DROP TEMPORARY FUNCTION IF EXISTS test_avg")
TestHive.reset()
}
test("SPARK-2693 udaf aggregates test") { test("SPARK-2693 udaf aggregates test") {
checkAnswer(sql("SELECT percentile(key, 1) FROM src LIMIT 1"), checkAnswer(sql("SELECT percentile(key, 1) FROM src LIMIT 1"),
sql("SELECT max(key) FROM src").collect().toSeq) sql("SELECT max(key) FROM src").collect().toSeq)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment