New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-20425][SQL] Support a vertical display mode for Dataset.show #17733
Conversation
Test build #76077 has finished for PR 17733 at commit
|
Test build #76078 has finished for PR 17733 at commit
|
Test build #76083 has finished for PR 17733 at commit
|
Test build #76084 has finished for PR 17733 at commit
|
Test build #76087 has finished for PR 17733 at commit
|
R/pkg/R/DataFrame.R
Outdated
@@ -194,6 +194,8 @@ setMethod("isLocal", | |||
#' 20 characters will be truncated. However, if set greater than zero, | |||
#' truncates strings longer than \code{truncate} characters and all cells | |||
#' will be aligned right. | |||
#' @param extendedMode enable expanded table formatting mode to print a column data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extendedMode
-> vertical
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, STGM. I'll update. Thanks!
* c2 | 0.8508820250344251 | ||
* c3 | 0.4593368817024575 | ||
* c4 | 0.2216918145613194 | ||
* c5 | 0.3756882647319614 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the same example, as shown above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
* @param numRows Number of rows to show | ||
* @param truncate If set to more than 0, truncates strings to `truncate` characters and | ||
* all cells will be aligned right. | ||
* @param extendedMode Enable expanded table formatting mode to print a column data per line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can follow what MySQL documents.
@param vertical Displays the result vertically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one? https://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html
Print query output rows vertically (one line per column value)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Test build #76166 has finished for PR 17733 at commit
|
}.getOrElse(0)) | ||
} | ||
|
||
dataRows.zipWithIndex.foreach { case (row, i) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the non-vertical output, when no row exists, we at least need to output the column names?
df.limit(0).show(20, 0, true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and found that both pg and mysql output no column name in the mode;
// pg
postgres=# create table t(a INT, b TEXT);
CREATE TABLE
postgres=# select * from t;
a | b
---+---
(0 rows)
postgres=# \x
Expanded display is on.
postgres=# select * from t;
(0 rows)
// mysql
mysql -u root --vertical
mysql> create table t(a INT, b TEXT);
Query OK, 0 rows affected (0.04 sec)
mysql> select * from t;
Empty set (0.00 sec)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, in this PR, we output nothing in this case. Postgres and MySQL at least output the message to indicate the result set is empty.
cc @cloud-fan @sameeragarwal @hvanhovell @rxin Any suggestion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, I see. I'll update. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for indicating that result set is empty. About displaying column names if the output is empty, perhaps it'd be best to stick with the postgres/mysql semantics.
Test build #76189 has finished for PR 17733 at commit
|
Jenkins, retest this please. |
Test build #76201 has finished for PR 17733 at commit
|
@gatorsmile Could you check again? Thanks! |
LGTM |
What changes were proposed in this pull request?
This pr added a new display mode for
Dataset.show
to print output rows vertically (one line per column value). In the current master, when printing Dataset with many columns, the readability is low like;psql
, CLI for PostgreSQL, supports a vertical display mode for this case like:http://stackoverflow.com/questions/9604723/alternate-output-format-for-psql
How was this patch tested?
Added tests in
DataFrameSuite
.