Github user NarineK commented on the pull request:

    https://github.com/apache/spark/pull/12836#issuecomment-216703595
  
    Hi @davies , 
    
    That's a very good question. Thank you for asking. 
    
    Here is my answer:
    gapply should be able to do grouping across partitions.
    Example - even if I set the number of partitions to 3 - the answer should 
be correct.
    
    df <- createDataFrame (
        sqlContext,
         list(list(1L, 2, "1", 0.1), list(3L, 1, "2", 0.2), list(1L, 3, "3", 
0.3)),
         c("a", "b", "c", "d"))
     df <- repartition(df, 3)
     schema <-  structType(structField("a", "integer"), structField("avg", 
"double"))
     df1 <- gapply(
         df,
         function(x) {
             y <- (data.frame(x$a[1], mean(x$b)))
         },
         schema, "a")
     collect(df1)
    
    Result
    ------------------------
      a avg
    1 1 2.5
    2 3 1.0
    
    In this case I do not care about the size and the number of the partition.
    
    I might understood your question wrongly. Please let me know if I've 
answered to your question.
    



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