You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/02/21 06:02:38 UTC

[GitHub] spark pull request #16594: [SPARK-17078] [SQL] Show stats when explain

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

    https://github.com/apache/spark/pull/16594#discussion_r102137142
  
    --- 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 --
    
    Always represent it using scientific notation? Or only do it when the number is too large?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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