Github user maropu commented on a diff in the pull request:
https://github.com/apache/spark/pull/6179#discussion_r31096485
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveUdfSuite.scala
---
@@ -133,6 +134,41 @@ class HiveUdfSuite extends QueryTest {
TestHive.reset()
}
+ test("UDFToListString") {
+ val testData = TestHive.sparkContext.parallelize(StringCaseClass("")
:: Nil).toDF()
+ testData.registerTempTable("inputTable")
+
+ /**
+ * Converts $"..." into UTF8String(...).
+ * TODO: Catalyst (e.g., CatalystTypeConverters) cannot convert
UTF8String
+ * into String correctly because of JVM type erasure.
+ */
+ implicit class StringToUtf8(val sc: StringContext) {
+ def u(args: Any*): UTF8String = UTF8String(sc.s(args :_*))
+ }
+
+ sql(s"CREATE TEMPORARY FUNCTION testUDFToListString AS
'${classOf[UDFToListString].getName}'")
+ checkAnswer(
+ sql("SELECT testUDFToListString(s) FROM inputTable"),
+ Seq(Row(u"data1" :: u"data2" :: u"data3" :: Nil)))
--- End diff --
Yes, some libraries already depend on this type of UDFs:
https://github.com/myui/hivemall/blob/master/src/main/java/hivemall/ftvec/AddBiasUDF.java#L37
Any idea to avoid this leaking?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]