Skip to content

Commit 5f923c0

Browse files
committed
Merge pull request #15 from shivaram/sparkr-groupby-retrain
Revert workaround in SparkR to retain grouped cols
2 parents b8b87e1 + c1de670 commit 5f923c0

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

R/pkg/R/group.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ setMethod("agg",
103103
}
104104
}
105105
jcols <- lapply(cols, function(c) { c@jc })
106-
# the GroupedData.agg(col, cols*) API does not contain grouping Column
107-
sdf <- callJStatic("org.apache.spark.sql.api.r.SQLUtils", "aggWithGrouping",
108-
x@sgd, listToSeq(jcols))
106+
sdf <- callJMethod(x@sgd, "agg", jcols[[1]], listToSeq(jcols[-1]))
109107
} else {
110108
stop("agg can only support Column or character")
111109
}

sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ private[r] object SQLUtils {
7272
sqlContext.createDataFrame(rowRDD, schema)
7373
}
7474

75-
// A helper to include grouping columns in Agg()
76-
def aggWithGrouping(gd: GroupedData, exprs: Column*): DataFrame = {
77-
val aggExprs = exprs.map { col =>
78-
col.expr match {
79-
case expr: NamedExpression => expr
80-
case expr: Expression => Alias(expr, expr.simpleString)()
81-
}
82-
}
83-
gd.toDF(aggExprs)
84-
}
85-
8675
def dfToRowRDD(df: DataFrame): JavaRDD[Array[Byte]] = {
8776
df.map(r => rowToRBytes(r))
8877
}

0 commit comments

Comments
 (0)