Github user wzhfy commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16594#discussion_r102398371
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/Statistics.scala
 ---
    @@ -54,11 +57,29 @@ case class Statistics(
     
       /** Readable string representation for the Statistics. */
       def simpleString: String = {
    -    Seq(s"sizeInBytes=$sizeInBytes",
    -      if (rowCount.isDefined) s"rowCount=${rowCount.get}" else "",
    +    Seq(s"sizeInBytes=${format(sizeInBytes, isSize = true)}",
    +      if (rowCount.isDefined) s"rowCount=${format(rowCount.get, isSize = 
false)}" else "",
           s"isBroadcastable=$isBroadcastable"
         ).filter(_.nonEmpty).mkString(", ")
       }
    +
    +  /** Show the given number in a readable format. */
    +  def format(number: BigInt, isSize: Boolean): String = {
    +    val decimalValue = BigDecimal(number, new MathContext(3, 
RoundingMode.HALF_UP))
    +    if (isSize) {
    +      // The largest unit in Utils.bytesToString is TB
    +      val PB = 1L << 50
    +      if (number < 2 * PB) {
    +        // The number is not very large, so we can use Utils.bytesToString 
to show it.
    +        Utils.bytesToString(number.toLong)
    +      } else {
    +        // The number is too large, show it in scientific notation.
    +        decimalValue.toString() + " B"
    +      }
    +    } else {
    +      decimalValue.toString()
    --- End diff --
    
    I'm not sure, will that be more readable than scientific notation if no 
unit?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to