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
1a3d0cd9
Commit
1a3d0cd9
authored
9 years ago
by
Reynold Xin
Browse files
Options
Downloads
Patches
Plain Diff
Revert "[SPARK-12105] [SQL] add convenient show functions"
This reverts commit
31b39101
.
parent
18ea11c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
+9
-16
9 additions, 16 deletions
sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
with
9 additions
and
16 deletions
sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala
+
9
−
16
View file @
1a3d0cd9
...
@@ -160,24 +160,17 @@ class DataFrame private[sql](
...
@@ -160,24 +160,17 @@ class DataFrame private[sql](
}
}
}
}
/**
* Compose the string representing rows for output
*/
def
showString
()
:
String
=
{
showString
(
20
)
}
/**
/**
* Compose the string representing rows for output
* Compose the string representing rows for output
* @param numRows Number of rows to show
* @param
_
numRows Number of rows to show
* @param truncate Whether truncate long strings and align cells right
* @param truncate Whether truncate long strings and align cells right
*/
*/
def
showString
(
numRows
:
Int
,
truncate
:
Boolean
=
true
)
:
String
=
{
private
[
sql
]
def
showString
(
_
numRows
:
Int
,
truncate
:
Boolean
=
true
)
:
String
=
{
val
_
numRows
=
numRows
.
max
(
0
)
val
numRows
=
_
numRows
.
max
(
0
)
val
sb
=
new
StringBuilder
val
sb
=
new
StringBuilder
val
takeResult
=
take
(
_
numRows
+
1
)
val
takeResult
=
take
(
numRows
+
1
)
val
hasMoreData
=
takeResult
.
length
>
_
numRows
val
hasMoreData
=
takeResult
.
length
>
numRows
val
data
=
takeResult
.
take
(
_
numRows
)
val
data
=
takeResult
.
take
(
numRows
)
val
numCols
=
schema
.
fieldNames
.
length
val
numCols
=
schema
.
fieldNames
.
length
// For array values, replace Seq and Array with square brackets
// For array values, replace Seq and Array with square brackets
...
@@ -231,10 +224,10 @@ class DataFrame private[sql](
...
@@ -231,10 +224,10 @@ class DataFrame private[sql](
sb
.
append
(
sep
)
sb
.
append
(
sep
)
// For Data that has more than "
_
numRows" records
// For Data that has more than "numRows" records
if
(
hasMoreData
)
{
if
(
hasMoreData
)
{
val
rowsString
=
if
(
_
numRows
==
1
)
"row"
else
"rows"
val
rowsString
=
if
(
numRows
==
1
)
"row"
else
"rows"
sb
.
append
(
s
"only showing top $
_
numRows $rowsString\n"
)
sb
.
append
(
s
"only showing top $numRows $rowsString\n"
)
}
}
sb
.
toString
()
sb
.
toString
()
...
...
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