Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
[NSE-337] UDF: Add test case for validating basic row-based udf (#338)
Browse files Browse the repository at this point in the history
Closes #337
  • Loading branch information
zhztheplayer authored May 25, 2021
1 parent c3f8471 commit ecaaeb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.apache.spark.sql.test.SharedSparkSession
class TPCDSSuite extends QueryTest with SharedSparkSession {

private val MAX_DIRECT_MEMORY = "6g"
private val TPCDS_QUERIES_RESOURCE = "tpcds-queries"
private val TPCDS_QUERIES_RESOURCE = "tpcds"
private val TPCDS_WRITE_PATH = "/tmp/tpcds-generated"

private var runner: TPCRunner = _
Expand Down Expand Up @@ -136,6 +136,15 @@ class TPCDSSuite extends QueryTest with SharedSparkSession {
df.explain()
df.show()
}

test("simple UDF") {
spark.udf.register("strLenScala",
(s: String) => Option(s).map(_.length).orElse(Option(0)).get)
val df = spark.sql("SELECT i_item_sk, i_item_desc, strLenScala(i_item_desc) FROM " +
"item LIMIT 100")
df.explain()
df.show()
}
}

object TPCDSSuite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import scala.collection.mutable.ArrayBuffer
class TPCHSuite extends QueryTest with SharedSparkSession {

private val MAX_DIRECT_MEMORY = "6g"
private val TPCH_QUERIES_RESOURCE = "tpch-queries"
private val TPCH_QUERIES_RESOURCE = "tpch"
private val TPCH_WRITE_PATH = "/tmp/tpch-generated"

private var runner: TPCRunner = _
Expand Down

0 comments on commit ecaaeb8

Please sign in to comment.