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

    https://github.com/apache/spark/pull/16696#discussion_r97933222
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/statsEstimation/StatsEstimationSuite.scala
 ---
    @@ -18,12 +18,41 @@
     package org.apache.spark.sql.catalyst.statsEstimation
     
     import org.apache.spark.sql.catalyst.CatalystConf
    -import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeMap, 
AttributeReference}
    -import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, 
LogicalPlan, Statistics}
    +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeMap, 
AttributeReference, Literal}
    +import org.apache.spark.sql.catalyst.plans.logical._
     import org.apache.spark.sql.types.IntegerType
     
     
    -class StatsConfSuite extends StatsEstimationTestBase {
    +class StatsEstimationSuite extends StatsEstimationTestBase {
    +  val (ar, colStat) = (attr("key"), ColumnStat(distinctCount = 10, min = 
Some(1), max = Some(10),
    +    nullCount = 0, avgLen = 4, maxLen = 4))
    +
    +  val plan = StatsTestPlan(
    +    outputList = Seq(ar),
    +    attributeStats = AttributeMap(Seq(ar -> colStat)),
    +    rowCount = 10,
    +    size = Some(10 * (8 + 4)))
    +
    +  test("limit estimation") {
    +    val localLimit = LocalLimit(Literal(2), plan)
    +    val globalLimit = GlobalLimit(Literal(2), plan)
    +    // LocalLimit and GlobalLimit share the same stats estimation logic.
    +    val expected = Statistics(sizeInBytes = 24, rowCount = Some(2))
    +    checkStats(localLimit, expected)
    +    checkStats(globalLimit, expected)
    +  }
    +
    +  test("sample estimation") {
    +    val sample = Sample(0.0, 0.5, withReplacement = false, (math.random * 
1000).toLong, plan)()
    +    checkStats(sample, expected = Statistics(sizeInBytes = 60, rowCount = 
Some(5)))
    +
    +    // Test if Sample's child doesn't have rowCount in stats
    +    val stats2 = Statistics(sizeInBytes = 120)
    +    val plan2 = DummyLogicalPlan(stats2, stats2)
    --- End diff --
    
    rename `plan2` to `childPlan`


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