Skip to content

Commit 3684fd2

Browse files
committed
[SPARK-5187][SQL] Fix caching of tables with HiveUDFs in the WHERE clause
Author: Michael Armbrust <michael@databricks.com> Closes #3987 from marmbrus/hiveUdfCaching and squashes the following commits: 8bca2fa [Michael Armbrust] [SPARK-5187][SQL] Fix caching of tables with HiveUDFs in the WHERE clause
1 parent 77106df commit 3684fd2

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/CachedTableSuite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,10 @@ class CachedTableSuite extends QueryTest {
158158
uncacheTable("src")
159159
assert(!isMaterialized(rddId), "Uncached in-memory table should have been unpersisted")
160160
}
161+
162+
test("CACHE TABLE with Hive UDF") {
163+
sql("CACHE TABLE udfTest AS SELECT * FROM src WHERE floor(key) = 1")
164+
assertCached(table("udfTest"))
165+
uncacheTable("udfTest")
166+
}
161167
}

sql/hive/v0.12.0/src/main/scala/org/apache/spark/sql/hive/Shim12.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import scala.language.implicitConversions
4444

4545
import org.apache.spark.sql.catalyst.types.DecimalType
4646

47-
class HiveFunctionWrapper(var functionClassName: String) extends java.io.Serializable {
47+
case class HiveFunctionWrapper(functionClassName: String) extends java.io.Serializable {
4848
// for Serialization
4949
def this() = this(null)
5050

sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim13.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import scala.language.implicitConversions
5353
*
5454
* @param functionClassName UDF class name
5555
*/
56-
class HiveFunctionWrapper(var functionClassName: String) extends java.io.Externalizable {
56+
case class HiveFunctionWrapper(var functionClassName: String) extends java.io.Externalizable {
5757
// for Serialization
5858
def this() = this(null)
5959

0 commit comments

Comments
 (0)