You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "VindhyaG (via GitHub)" <gi...@apache.org> on 2023/03/25 19:18:32 UTC

[GitHub] [spark] VindhyaG opened a new pull request, #40553: [SPARK-39722] [SQL] getString API for Dataset

VindhyaG opened a new pull request, #40553:
URL: https://github.com/apache/spark/pull/40553

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   Add getString API for Dataset for usecases where string representation needs to be used other than stdout(println)
   More details in the bug
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   But there are a lot of cases where we might need to get a String representation of the show output. For example
   
    logging framework to which we need to push the representation of a df
    send the string over a REST call from the driver
   send the string to stderr instead of stdout
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Tested locally using spark-shell


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1151950076


##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -883,6 +883,129 @@ class Dataset[T] private[sql](
     println(showString(numRows, truncate, vertical))
   // scalastyle:on println
 
+  /**
+   * Gets top 20 rows of Dataset as string in a tabular form. Strings more than 20 characters
+   * will be truncated, and all cells will be aligned right.
+   *
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(): String = getString(20)
+
+  /**
+   * Gets the Dataset in a tabular form. Strings more than 20 characters will be truncated,
+   * and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows Number of rows to show
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(numRows: Int): String = getString(numRows, truncate = true)
+
+  /**
+   * Gets the top 20 rows of Dataset as string in a tabular form.
+   *
+   * @param truncate Whether truncate long strings. If true, strings more than 20 characters will
+   *                 be truncated and all cells will be aligned right
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(truncate: Boolean): String = getString(20, truncate)
+
+  /**
+   * Gets top 20 rows of Dataset as string in a tabular form.
+   *
+   * @param truncate Whether truncate long strings. If true, strings more than 20 characters will
+   *                 be truncated and all cells will be aligned right
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(numRows: Int, truncate: Boolean): String = if (truncate) {
+    showString(numRows, truncate = 20)
+  } else {
+    showString(numRows, truncate = 0)
+  }
+
+  /**
+   * Gets the Dataset as string in a tabular form. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @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.
+   * @group action

Review Comment:
   i am not sure what should be the group these apis come under.  this wont be an action but not sure what is the group i need to add



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1151936705


##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -883,6 +883,129 @@ class Dataset[T] private[sql](
     println(showString(numRows, truncate, vertical))
   // scalastyle:on println
 
+  /**
+   * Gets top 20 rows of Dataset as string in a tabular form. Strings more than 20 characters
+   * will be truncated, and all cells will be aligned right.
+   *
+   * @group action
+   * @since 3.5.0

Review Comment:
   Thanks for reviewing @jaceklaskowski .  I took the version from one of the recent bugs but i realised i took the affected version instead of fix version which is wrong. I am trying to get details on how to get current release version to add but not able to find any links i can be confident on .  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1490823634

   > Do you think, a more interesting way can be returning a JSON representation?
   For rest api yes JSON would make more sense but for logging i suppose string in tabular form is more useful? may be have a separate API for that ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1151938443


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -535,6 +535,159 @@ class Dataset[T] private[sql] (
     }
   }
 
+  /**
+   * Gets the Dataset as string in a tabular form. Strings more than 20 characters will be
+   * truncated, and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows
+   *   Number of rows to show
+   * @group action
+   * @since 3.4.0

Review Comment:
   I missed changing version number . will change once i can figure out what is the current release cycle is on? Can you please point me where i can get that info .thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1490821588

   > I see this as developer facing API, So just having
   > 
   > ```
   > def getString(numRows: Int, truncate: Int): String =
   >      getString(numRows, truncate, vertical = false)
   > ```
   > 
   > would suffice.
   
   my intention was to keep it consistent with show() where if numrows and truncate have default values 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1497599094

   @ScrapCodes can you pls suggest further on this?
   @jaceklaskowski  have updated the versions. can you pls review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1484000722

   @rxin @ScrapCodes @maropu  can you please review . thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] ScrapCodes commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "ScrapCodes (via GitHub)" <gi...@apache.org>.
ScrapCodes commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1489811022

   Hi @VindhyaG, this might be useful - may be we can benefit from the usecase you have for this. Is it just for logging? 
   Not sure what others think, it might be good to limit the API surface. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1153193529


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -535,6 +535,159 @@ class Dataset[T] private[sql] (
     }
   }
 
+  /**
+   * Gets the Dataset as string in a tabular form. Strings more than 20 characters will be
+   * truncated, and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows
+   *   Number of rows to show
+   * @group action
+   * @since 3.4.0

Review Comment:
   This was added on its own. not sure why?
   
   > Hi @VindhyaG, this might be useful - may be we can benefit from the usecase you have for this. Is it just for logging? Not sure what others think, it might be good to limit the API surface.
   
   @ScrapCodes Thanks for reviewing.  bug  lists the three reasons which i have listed in PR description above. Do you have any specific suggestions to limit API surface?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1490227613

   > Hi @VindhyaG, this might be useful - may be we can benefit from the usecase you have for this. Is it just for logging? Not sure what others think, it might be good to limit the API surface.
   
   @ScrapCodes thanks for reviewing. Bug lists three ways API could be used which i have added in PR description above. Do you have any suggestions to limit API surface?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] ScrapCodes commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "ScrapCodes (via GitHub)" <gi...@apache.org>.
ScrapCodes commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1490457386

   Do you think, a more interesting way can be returning a JSON representation?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] github-actions[bot] commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1636581128

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1151950076


##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -883,6 +883,129 @@ class Dataset[T] private[sql](
     println(showString(numRows, truncate, vertical))
   // scalastyle:on println
 
+  /**
+   * Gets top 20 rows of Dataset as string in a tabular form. Strings more than 20 characters
+   * will be truncated, and all cells will be aligned right.
+   *
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(): String = getString(20)
+
+  /**
+   * Gets the Dataset in a tabular form. Strings more than 20 characters will be truncated,
+   * and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows Number of rows to show
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(numRows: Int): String = getString(numRows, truncate = true)
+
+  /**
+   * Gets the top 20 rows of Dataset as string in a tabular form.
+   *
+   * @param truncate Whether truncate long strings. If true, strings more than 20 characters will
+   *                 be truncated and all cells will be aligned right
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(truncate: Boolean): String = getString(20, truncate)
+
+  /**
+   * Gets top 20 rows of Dataset as string in a tabular form.
+   *
+   * @param truncate Whether truncate long strings. If true, strings more than 20 characters will
+   *                 be truncated and all cells will be aligned right
+   * @group action
+   * @since 3.5.0
+   */
+  def getString(numRows: Int, truncate: Boolean): String = if (truncate) {
+    showString(numRows, truncate = 20)
+  } else {
+    showString(numRows, truncate = 0)
+  }
+
+  /**
+   * Gets the Dataset as string in a tabular form. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @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.
+   * @group action

Review Comment:
   i am not sure what should be the group these apis come under.  this wont be an action but not sure what is the group i need to add



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1153193529


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -535,6 +535,159 @@ class Dataset[T] private[sql] (
     }
   }
 
+  /**
+   * Gets the Dataset as string in a tabular form. Strings more than 20 characters will be
+   * truncated, and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows
+   *   Number of rows to show
+   * @group action
+   * @since 3.4.0

Review Comment:
   This was added on its own. not sure why?
   
   > Hi @VindhyaG, this might be useful - may be we can benefit from the usecase you have for this. Is it just for logging? Not sure what others think, it might be good to limit the API surface.
   
   
   
   > I missed changing version number . will change once i can figure out what is the current release cycle is on? Can you please point me where i can get that info .thanks!
   
   
   
   > Hi @VindhyaG, this might be useful - may be we can benefit from the usecase you have for this. Is it just for logging? Not sure what others think, it might be good to limit the API surface.
   
   
   
   > Hi @VindhyaG, this might be useful - may be we can benefit from the usecase you have for this. Is it just for logging? Not sure what others think, it might be good to limit the API surface.
   
   @ScrapCodes Thanks for reviewing.  bug  lists the three reasons which i have listed in PR description above. Do you have any specific suggestions to limit API surface?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] jaceklaskowski commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "jaceklaskowski (via GitHub)" <gi...@apache.org>.
jaceklaskowski commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1149025286


##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -883,6 +883,129 @@ class Dataset[T] private[sql](
     println(showString(numRows, truncate, vertical))
   // scalastyle:on println
 
+  /**
+   * Gets top 20 rows of Dataset as string in a tabular form. Strings more than 20 characters
+   * will be truncated, and all cells will be aligned right.
+   *
+   * @group action
+   * @since 3.5.0

Review Comment:
   nit: Why is this `3.5.0`?



##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -535,6 +535,159 @@ class Dataset[T] private[sql] (
     }
   }
 
+  /**
+   * Gets the Dataset as string in a tabular form. Strings more than 20 characters will be
+   * truncated, and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows
+   *   Number of rows to show
+   * @group action
+   * @since 3.4.0

Review Comment:
   nit: Why is this `3.4.0` while the latter changes are marked as `3.5.0`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] VindhyaG commented on a diff in pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "VindhyaG (via GitHub)" <gi...@apache.org>.
VindhyaG commented on code in PR #40553:
URL: https://github.com/apache/spark/pull/40553#discussion_r1153437032


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -535,6 +535,159 @@ class Dataset[T] private[sql] (
     }
   }
 
+  /**
+   * Gets the Dataset as string in a tabular form. Strings more than 20 characters will be
+   * truncated, and all cells will be aligned right. For example:
+   * {{{
+   *   year  month AVG('Adj Close) MAX('Adj Close)
+   *   1980  12    0.503218        0.595103
+   *   1981  01    0.523289        0.570307
+   *   1982  02    0.436504        0.475256
+   *   1983  03    0.410516        0.442194
+   *   1984  04    0.450090        0.483521
+   * }}}
+   *
+   * @param numRows
+   *   Number of rows to show
+   * @group action
+   * @since 3.4.0

Review Comment:
   @jaceklaskowski updated to 3.5.0 based on recently(hours ago) closed bug fix version of SQL and Java API component



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] ScrapCodes commented on pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "ScrapCodes (via GitHub)" <gi...@apache.org>.
ScrapCodes commented on PR #40553:
URL: https://github.com/apache/spark/pull/40553#issuecomment-1490453383

   I see this as developer facing API, So just having 
   ```
   def getString(numRows: Int, truncate: Int): String =
        getString(numRows, truncate, vertical = false)
   ```
   would suffice.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] github-actions[bot] closed pull request #40553: [SPARK-39722] [SQL] getString API for Dataset

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #40553: [SPARK-39722] [SQL] getString API for Dataset
URL: https://github.com/apache/spark/pull/40553


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org