Skip to content

Commit

Permalink
Add test case for arbitrary function call in UDF
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Xu <allxu@nvidia.com>
  • Loading branch information
wjxiz1992 authored and seanprime7 committed Oct 26, 2020
1 parent 1b58b68 commit 2e81d82
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions udf-compiler/src/test/scala/com/nvidia/spark/OpcodeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class OpcodeSuite extends FunSuite {

val conf: SparkConf = new SparkConf()
.set("spark.sql.extensions", "com.nvidia.spark.udf.Plugin")
.set("spark.rapids.sql.test.enabled", "true")
.set("spark.rapids.sql.udfCompiler.enabled", "true")
.set(RapidsConf.EXPLAIN.key, "true")

Expand Down Expand Up @@ -2086,4 +2087,20 @@ class OpcodeSuite extends FunSuite {
val ref = dataset.select(lit(Array.empty[String]).as("emptyArrOfStr"))
checkEquiv(result, ref)
}

test("Arbitrary function call inside UDF - ") {
def simple_func(str: String): Int = {
str.length
}
val myudf: (String) => Int = str => {
simple_func(str)
}
val u = makeUdf(myudf)
val dataset = List("hello", "world").toDS()
val result = dataset.withColumn("new", u(col("value")))
val ref = dataset.withColumn("new", length(col("value")))
result.explain(true)
result.show
// checkEquiv(result, ref)
}
}

0 comments on commit 2e81d82

Please sign in to comment.