[SPARK-30179][SQL][TESTS] Improve test in SingleSessionSuite

### What changes were proposed in this pull request?

improve the temporary functions test in SingleSessionSuite by verifying the result in a query

### Why are the changes needed?

### Does this PR introduce any user-facing change?

### How was this patch tested?

Closes #26812 from leoluan2009/SPARK-30179.

Authored-by: Luan <xuluan@ebay.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
This commit is contained in:
Luan 2019-12-10 10:57:32 +09:00 committed by HyukjinKwon
parent 36fa1980c2
commit 3d98c9f985

View file

@ -790,6 +790,8 @@ class SingleSessionSuite extends HiveThriftJdbcTest {
Seq(
"SET foo=bar",
s"ADD JAR $jarURL",
"CREATE TABLE test_udtf(key INT, value STRING) USING hive",
s"LOAD DATA LOCAL INPATH '${TestData.smallKv}' OVERWRITE INTO TABLE test_udtf",
s"""CREATE TEMPORARY FUNCTION udtf_count2
|AS 'org.apache.spark.sql.hive.execution.GenericUDTFCount2'
""".stripMargin
@ -816,6 +818,16 @@ class SingleSessionSuite extends HiveThriftJdbcTest {
assert(rs2.next())
assert(rs2.getString(1) === "Usage: N/A.")
val rs3 = statement.executeQuery(
"SELECT key, cc FROM test_udtf LATERAL VIEW udtf_count2(value) dd AS cc")
assert(rs3.next())
assert(rs3.getInt(1) === 165)
assert(rs3.getInt(2) === 5)
assert(rs3.next())
assert(rs3.getInt(1) === 165)
assert(rs3.getInt(2) === 5)
} finally {
statement.executeQuery("DROP TEMPORARY FUNCTION udtf_count2")
}