You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2016/12/03 07:52:14 UTC

[GitHub] spark pull request #16068: [SPARK-18637][SQL]Stateful UDF should be consider...

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

    https://github.com/apache/spark/pull/16068#discussion_r90752814
  
    --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveUDFSuite.scala ---
    @@ -487,6 +488,29 @@ class HiveUDFSuite extends QueryTest with TestHiveSingleton with SQLTestUtils {
         assert(count4 == 1)
         sql("DROP TABLE parquet_tmp")
       }
    +
    +  test("Hive Stateful UDF") {
    +    sql(s"CREATE TEMPORARY FUNCTION statefulUDF AS '${classOf[StatefulUDF].getName}'")
    +    sql(s"CREATE TEMPORARY FUNCTION statelessUDF AS '${classOf[StatelessUDF].getName}'")
    +    val testData = spark.sparkContext.parallelize(
    +      (0 until 10) map(x => IntegerCaseClass(1)), 2).toDF()
    +    testData.createOrReplaceTempView("inputTable")
    +    val max1 =
    +      sql("SELECT MAX(s) FROM (" +
    +        "SELECT statefulUDF() as s FROM (SELECT i from inputTable DISTRIBUTE by i) a" +
    +        ") b").head().getLong(0)
    --- End diff --
    
    How about using multiline string syntax here?
    ```Scala
        sql(
          """
            |SELECT MAX(s) FROM
            |  (SELECT statefulUDF() as s FROM
            |    (SELECT i from inputTable DISTRIBUTE BY i) a
            |  ) b
          """.stripMargin)
    ```



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org