maropu commented on a change in pull request #32498:
URL: https://github.com/apache/spark/pull/32498#discussion_r630844778



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -759,6 +759,10 @@ case class Range(
   }
 
   override def computeStats(): Statistics = {
+    if (!conf.cboEnabled) {
+      return Statistics(sizeInBytes = LongType.defaultSize * numElements)
+    }
+

Review comment:
       We need this?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -767,14 +771,44 @@ case class Range(
       } else {
         (start + (numElements - 1) * step, start)
       }
-      val colStat = ColumnStat(
+      var colStat = ColumnStat(

Review comment:
       Please avoid using `var` where possible.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -767,14 +771,44 @@ case class Range(
       } else {
         (start + (numElements - 1) * step, start)
       }
-      val colStat = ColumnStat(
+      var colStat = ColumnStat(
         distinctCount = Some(numElements),
         max = Some(maxVal),
         min = Some(minVal),
         nullCount = Some(0),
         avgLen = Some(LongType.defaultSize),
         maxLen = Some(LongType.defaultSize))
 
+      if (conf.histogramEnabled) {
+

Review comment:
       please remove this blank.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -767,14 +771,44 @@ case class Range(
       } else {
         (start + (numElements - 1) * step, start)
       }
-      val colStat = ColumnStat(
+      var colStat = ColumnStat(
         distinctCount = Some(numElements),
         max = Some(maxVal),
         min = Some(minVal),
         nullCount = Some(0),
         avgLen = Some(LongType.defaultSize),
         maxLen = Some(LongType.defaultSize))
 
+      if (conf.histogramEnabled) {
+
+        def getRangeValue(index: Int): Long = {

Review comment:
       How about extracting this inner method as a private method?




-- 
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.

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



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

Reply via email to