Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
9baac56c
Commit
9baac56c
authored
10 years ago
by
Reynold Xin
Browse files
Options
Downloads
Patches
Plain Diff
Minor fixes for commit
https://github.com/apache/spark/pull/4592
.
parent
5c78be7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sql/core/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala
+3
-3
3 additions, 3 deletions
...e/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala
sql/core/src/main/scala/org/apache/spark/sql/GroupedData.scala
+4
-5
4 additions, 5 deletions
...ore/src/main/scala/org/apache/spark/sql/GroupedData.scala
with
7 additions
and
8 deletions
sql/core/src/main/scala/org/apache/spark/sql/DataFrameImpl.scala
+
3
−
3
View file @
9baac56c
...
...
@@ -83,17 +83,17 @@ private[sql] class DataFrameImpl protected[sql](
protected
[
sql
]
def
resolve
(
colName
:
String
)
:
NamedExpression
=
{
queryExecution
.
analyzed
.
resolve
(
colName
,
sqlContext
.
analyzer
.
resolver
).
getOrElse
{
throw
new
Runtime
Exception
(
throw
new
Analysis
Exception
(
s
"""Cannot resolve column name "$colName" among (${schema.fieldNames.mkString(", ")})"""
)
}
}
protected
[
sql
]
def
numericColumns
()
:
Seq
[
Expression
]
=
{
protected
[
sql
]
def
numericColumns
:
Seq
[
Expression
]
=
{
schema
.
fields
.
filter
(
_
.
dataType
.
isInstanceOf
[
NumericType
]).
map
{
n
=>
queryExecution
.
analyzed
.
resolve
(
n
.
name
,
sqlContext
.
analyzer
.
resolver
).
get
}
}
override
def
toDF
(
colNames
:
String*
)
:
DataFrame
=
{
require
(
schema
.
size
==
colNames
.
size
,
"The number of columns doesn't match.\n"
+
...
...
This diff is collapsed.
Click to expand it.
sql/core/src/main/scala/org/apache/spark/sql/GroupedData.scala
+
4
−
5
View file @
9baac56c
...
...
@@ -17,8 +17,8 @@
package
org.apache.spark.sql
import
scala.language.implicitConversions
import
scala.collection.JavaConversions._
import
scala.language.implicitConversions
import
org.apache.spark.sql.catalyst.analysis.Star
import
org.apache.spark.sql.catalyst.expressions._
...
...
@@ -26,7 +26,6 @@ import org.apache.spark.sql.catalyst.plans.logical.Aggregate
import
org.apache.spark.sql.types.NumericType
/**
* A set of methods for aggregations on a [[DataFrame]], created by [[DataFrame.groupBy]].
*/
...
...
@@ -48,13 +47,13 @@ class GroupedData protected[sql](df: DataFrameImpl, groupingExprs: Seq[Expressio
// No columns specified. Use all numeric columns.
df
.
numericColumns
}
else
{
// Make sure all specified columns are numeric
// Make sure all specified columns are numeric
.
colNames
.
map
{
colName
=>
val
namedExpr
=
df
.
resolve
(
colName
)
if
(!
namedExpr
.
dataType
.
isInstanceOf
[
NumericType
])
{
throw
new
AnalysisException
(
s
""""$colName" is not a numeric column. """
+
"Aggregation function can only be
perform
ed on a numeric column."
)
"Aggregation function can only be
appli
ed on a numeric column."
)
}
namedExpr
}
...
...
@@ -64,7 +63,7 @@ class GroupedData protected[sql](df: DataFrameImpl, groupingExprs: Seq[Expressio
Alias
(
a
,
a
.
toString
)()
}
}
private
[
this
]
def
strToExpr
(
expr
:
String
)
:
(
Expression
=>
Expression
)
=
{
expr
.
toLowerCase
match
{
case
"avg"
|
"average"
|
"mean"
=>
Average
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment