Github user NarineK commented on a diff in the pull request:
https://github.com/apache/spark/pull/12836#discussion_r67264555
--- Diff: R/pkg/R/DataFrame.R ---
@@ -1266,6 +1266,83 @@ setMethod("dapplyCollect",
ldf
})
+#' gapply
+#'
+#' Group the SparkDataFrame using the specified columns and apply the R
function to each
+#' group.
+#'
+#' @param x A SparkDataFrame
+#' @param cols Grouping columns
+#' @param func A function to be applied to each group partition specified
by grouping
+#' column of the SparkDataFrame. The function `func` takes as
argument
+#' a key - grouping columns and a data frame - a local R
data.frame.
+#' The output of `func` is a local R data.frame.
+#' @param schema The schema of the resulting SparkDataFrame after the
function is applied.
--- End diff --
The output schema is purely based on the output dataframe, if key is
included in the output then we need to include the key to the schema.
Basically, the schema has to match to what we want to output. If we want to
output only the average in the above example, we could have:
schema <- structType(structField("avg", "double")),
what really matters is the data-type - it has to be double in above
example, it cannot be string or character .... The name doesn't matter either.
I could have "hello", instead "avg'.
---
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]