uncleGen commented on a change in pull request #24961: [SPARK-28158][SQL] Hive 
UDFs supports UDT type
URL: https://github.com/apache/spark/pull/24961#discussion_r327990724
 
 

 ##########
 File path: mllib/src/test/scala/org/apache/spark/ml/linalg/VectorUDTSuite.scala
 ##########
 @@ -44,4 +45,39 @@ class VectorUDTSuite extends SparkFunSuite {
     assert(dataType.asInstanceOf[StructType].fields.map(_.dataType)
       === Seq(new VectorUDT, DoubleType))
   }
+
+  test("SPARK-28158 Hive UDFs supports UDT type") {
+    val functionName = "Logistic_Regression"
+    val sql = spark.sql _
+    try {
+      val df = spark.read.format("libsvm").options(Map("vectorType" -> 
"dense"))
+        
.load(TestHive.getHiveFile("test-data/libsvm/sample_libsvm_data.txt").getPath)
+      df.createOrReplaceTempView("src")
+
+      // `Logistic_Regression` accepts features (with Vector type), and 
returns the
+      // prediction value. To simplify the UDF implementation, the 
`Logistic_Regression`
+      // will return 0.95d directly.
+      sql(
+        s"""
+           |CREATE FUNCTION Logistic_Regression
+           |AS 'org.apache.spark.sql.hive.LogisticRegressionUDF'
+           |USING JAR '${TestHive.getHiveFile("TestLogRegUDF.jar").toURI}'
 
 Review comment:
   remove this jar

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to