Github user yhuai commented on the pull request:

    https://github.com/apache/spark/pull/9038#issuecomment-148213519
  
    I tried the UDAF in 
https://databricks.com/blog/2015/09/16/spark-1-5-dataframe-api-highlights-datetimestring-handling-time-intervals-and-udafs.html.
 I tried the following test in `build/sbt -Phive sparkShell`.
    ```
    // Generating data
    sc
      .parallelize(1 to 1000, 1)
      .flatMap(i => (1 to 20000).map(j => (i, j, j, j, j, j, j, j, j, j, j)))
      .toDF("i", "j1", "j2", "j3", "j4", "j5", "j6", "j7", "j8", "j9", "j10")
      .write
      .format("parquet")
      .saveAsTable("testAgg")
    
    // Run query.
    import org.apache.spark.sql.functions._
    
    val gm = new GeometricMean
    sqlContext.udf.register("gm", gm)
    
    sqlContext.sql("set spark.sql.shuffle.partitions=1")
    
sqlContext.read.load("/user/hive/warehouse/testagg").registerTempTable("testAgg")
    
    val start = System.currentTimeMillis
    (1 to 10).foreach { i=>
    sqlContext.sql("""
      select
        i,
        gm(j1),
        gm(j2),
        gm(j3),
        gm(j4),
        gm(j5),
        sum(j6),
        sum(j7),
        sum(j8),
        sum(j9),
        sum(j10)
      from testAgg
      group by i""").queryExecution.executedPlan.execute().foreach(x => Unit)
    }
    println("took " + ((System.currentTimeMillis - start).toDouble / 1000/10))
    ```
    Without this PR, the avg execution time was 31.6s. With this PR, the avg 
execution time was 27.8s. 


---
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