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

[NSE-337] UDF: Add test case for validating basic row-based udf #338

Merged
merged 2 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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