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

    https://github.com/apache/spark/pull/15959#discussion_r89267570
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/StatisticsCollectionSuite.scala ---
    @@ -0,0 +1,218 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql
    +
    +import java.{lang => jl}
    +import java.sql.{Date, Timestamp}
    +
    +import scala.collection.mutable
    +
    +import org.apache.spark.sql.catalyst.TableIdentifier
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.execution.datasources.LogicalRelation
    +import org.apache.spark.sql.test.{SharedSQLContext, SQLTestUtils}
    +import org.apache.spark.sql.test.SQLTestData.ArrayData
    +import org.apache.spark.sql.types._
    +
    +
    +/**
    + * End-to-end suite testing statistics collection and use on both entire 
table and columns.
    + */
    +class StatisticsCollectionSuite extends StatisticsCollectionTestBase with 
SharedSQLContext {
    +  import testImplicits._
    +
    +  private def checkTableStats(tableName: String, expectedRowCount: 
Option[Int])
    +    : Option[Statistics] = {
    +    val df = spark.table(tableName)
    +    val stats = df.queryExecution.analyzed.collect { case rel: 
LogicalRelation =>
    +      assert(rel.catalogTable.get.stats.flatMap(_.rowCount) === 
expectedRowCount)
    +      rel.catalogTable.get.stats
    +    }
    +    assert(stats.size == 1)
    +    stats.head
    +  }
    +
    +  test("estimates the size of a limit 0 on outer join") {
    +    withTempView("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"number of Join nodes is wrong:\n 
${df.queryExecution}")
    +      assert(sizes.head === BigInt(96),
    --- End diff --
    
    This is just code move around - it was the old test.



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