Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 7302319

Browse files
cancel the implicit keyword
1 parent a66e38f commit 7302319

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

sql/core/src/main/scala/org/apache/spark/sql/GroupedData.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class GroupedData protected[sql](
6969
df: DataFrame,
7070
groupingExprs: Seq[Expression],
7171
private val groupType: GroupedData.GroupType) {
72-
private[sql] implicit def toDF(aggExprs: Seq[NamedExpression]): DataFrame = {
72+
73+
private[this] def toDF(aggExprs: Seq[NamedExpression]): DataFrame = {
7374
val aggregates = if (df.sqlContext.conf.dataFrameRetainGroupColumns) {
7475
val retainedExprs = groupingExprs.map {
7576
case expr: NamedExpression => expr
@@ -94,7 +95,7 @@ class GroupedData protected[sql](
9495
}
9596

9697
private[this] def aggregateNumericColumns(colNames: String*)(f: Expression => Expression)
97-
: Seq[NamedExpression] = {
98+
: DataFrame = {
9899

99100
val columnExprs = if (colNames.isEmpty) {
100101
// No columns specified. Use all numeric columns.
@@ -111,10 +112,10 @@ class GroupedData protected[sql](
111112
namedExpr
112113
}
113114
}
114-
columnExprs.map { c =>
115+
toDF(columnExprs.map { c =>
115116
val a = f(c)
116117
Alias(a, a.prettyString)()
117-
}
118+
})
118119
}
119120

120121
private[this] def strToExpr(expr: String): (Expression => Expression) = {
@@ -167,10 +168,10 @@ class GroupedData protected[sql](
167168
* @since 1.3.0
168169
*/
169170
def agg(exprs: Map[String, String]): DataFrame = {
170-
exprs.map { case (colName, expr) =>
171+
toDF(exprs.map { case (colName, expr) =>
171172
val a = strToExpr(expr)(df(colName).expr)
172173
Alias(a, a.prettyString)()
173-
}.toSeq
174+
}.toSeq)
174175
}
175176

176177
/**
@@ -223,10 +224,10 @@ class GroupedData protected[sql](
223224
*/
224225
@scala.annotation.varargs
225226
def agg(expr: Column, exprs: Column*): DataFrame = {
226-
(expr +: exprs).map(_.expr).map {
227+
toDF((expr +: exprs).map(_.expr).map {
227228
case expr: NamedExpression => expr
228229
case expr: Expression => Alias(expr, expr.prettyString)()
229-
}
230+
})
230231
}
231232

232233
/**
@@ -235,7 +236,7 @@ class GroupedData protected[sql](
235236
*
236237
* @since 1.3.0
237238
*/
238-
def count(): DataFrame = Seq(Alias(Count(Literal(1)), "count")())
239+
def count(): DataFrame = toDF(Seq(Alias(Count(Literal(1)), "count")()))
239240

240241
/**
241242
* Compute the average value for each numeric columns for each group. This is an alias for `avg`.

0 commit comments

Comments
 (0)