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

    https://github.com/apache/spark/pull/14034#discussion_r69528969
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/StatisticsSuite.scala ---
    @@ -31,4 +33,46 @@ class StatisticsSuite extends QueryTest with 
SharedSQLContext {
           spark.sessionState.conf.autoBroadcastJoinThreshold)
       }
     
    +  test("estimates the size of limit") {
    +    withTempTable("test") {
    +      Seq(("one", 1), ("two", 2), ("three", 3), ("four", 4)).toDF("k", "v")
    +        .createOrReplaceTempView("test")
    +      Seq((0, 1), (1, 24), (2, 48)).foreach { case (limit, expected) =>
    +        val df = sql(s"""SELECT * FROM test limit $limit""")
    +
    +        val sizesGlobalLimit = df.queryExecution.analyzed.collect { case 
g: GlobalLimit =>
    +          g.statistics.sizeInBytes
    +        }
    +        assert(sizesGlobalLimit.size === 1, s"Size wrong for:\n 
${df.queryExecution}")
    +        assert(sizesGlobalLimit(0).equals(BigInt(expected)),
    +          s"expected exact size 24 for table 'test', got: 
${sizesGlobalLimit(0)}")
    +
    +        val sizesLocalLimit = df.queryExecution.analyzed.collect { case l: 
LocalLimit =>
    +          l.statistics.sizeInBytes
    +        }
    +        assert(sizesLocalLimit.size === 1, s"Size wrong for:\n 
${df.queryExecution}")
    +        assert(sizesLocalLimit(0).equals(BigInt(expected)),
    +          s"expected exact size 24 for table 'test', got: 
${sizesLocalLimit(0)}")
    +      }
    +    }
    +  }
    +
    +  test("estimates the size of a limit 0 on outer join") {
    +    withTempTable("test") {
    +      Seq(("one", 1), ("two", 2), ("three", 3), ("four", 4)).toDF("k", "v")
    +        .createOrReplaceTempView("test")
    +      val df1 = spark.table("test")
    +      val df2 = spark.table("test").limit(0)
    +      val df = df1.join(df2, Seq("k"), "left")
    +
    +      val sizes = df.queryExecution.analyzed.collect { case g: Join =>
    +        g.statistics.sizeInBytes
    +      }
    +
    +      assert(sizes.size === 1, s"Size wrong for:\n ${df.queryExecution}")
    +      assert(sizes(0).equals(BigInt(96)),
    --- End diff --
    
    Why do you `equals`? Would `===` not work here?


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