Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2621#discussion_r18433074
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveUdfSuite.scala 
---
    @@ -83,6 +86,82 @@ class HiveUdfSuite extends HiveComparisonTest {
       test("SPARK-2693 udaf aggregates test") {
         assert(sql("SELECT percentile(key,1) FROM src").first === sql("SELECT 
max(key) FROM src").first)
       }
    +
    +  test("UDFIntegerToString") {
    +    val testData = TestHive.sparkContext.parallelize(
    +      IntegerCaseClass(1) :: IntegerCaseClass(2) :: Nil)
    +    testData.registerTempTable("integerTable")
    +
    +    sql(s"CREATE TEMPORARY FUNCTION testUDFIntegerToString AS 
'${classOf[UDFIntegerToString].getName}'")
    +    assertResult(Array(Array("1"), Array("2"))) {
    +      sql("SELECT testUDFIntegerToString(i) FROM integerTable").collect()
    +    }
    +    sql("DROP TEMPORARY FUNCTION IF EXISTS testUDFIntegerToString")
    +
    +    TestHive.reset()
    +  }
    +
    +  test("UDFListListInt") {
    +    val testData = TestHive.sparkContext.parallelize(
    +      ListListIntCaseClass(Nil) ::
    +      ListListIntCaseClass(Seq(new Tuple3(1, 2, 3))) ::
    +      ListListIntCaseClass(Seq(new Tuple3(4, 5, 6), new Tuple3(7, 8, 9))) 
:: Nil)
    +    testData.registerTempTable("listListIntTable")
    +
    +    sql(s"CREATE TEMPORARY FUNCTION testUDFListListInt AS 
'${classOf[UDFListListInt].getName}'")
    +    assertResult(Array(Array(0), Array(2), Array(13))) {
    +      sql("SELECT testUDFListListInt(lli) FROM listListIntTable").collect()
    +    }
    --- End diff --
    
    Use `checkAnswer` from `QueryTest` to test queries.  It compare answers, 
gives side by side results when they differ, and prints better exceptions.
    
    ```scala
    checkAnswer(
      sql("SELECT testUDFIntegerToString(i) FROM integerTable"),
      Seq(Row(1), Row(2)))
    ```  
    
    Actually, mind fixing the one above too?  I let that slip in somehow.  
Thanks :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to