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

    https://github.com/apache/spark/pull/14712#discussion_r77610557
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala ---
    @@ -168,6 +171,154 @@ class StatisticsSuite extends QueryTest with 
TestHiveSingleton with SQLTestUtils
           TableIdentifier("tempTable"), ignoreIfNotExists = true, purge = 
false)
       }
     
    +  private def checkMetastoreRelationStats(
    +      tableName: String,
    +      expectedStats: Option[Statistics]): Unit = {
    +    val df = sql(s"SELECT * FROM $tableName")
    +    val relations = df.queryExecution.analyzed.collect { case rel: 
MetastoreRelation =>
    +      expectedStats match {
    +        case Some(es) =>
    +          assert(rel.catalogTable.stats.isDefined)
    +          val stats = rel.catalogTable.stats.get
    +          assert(stats.sizeInBytes === es.sizeInBytes)
    +          assert(stats.rowCount === es.rowCount)
    +        case None =>
    +          assert(rel.catalogTable.stats.isEmpty)
    +      }
    +      rel
    +    }
    +    assert(relations.size === 1)
    +  }
    +
    +  test("test table-level statistics for hive tables created in 
HiveExternalCatalog") {
    +    val textTable = "textTable"
    +    withTable(textTable) {
    +      // Currently Spark's statistics are self-contained, we don't have 
statistics until we use
    +      // the `ANALYZE TABLE` command.
    +      sql(s"CREATE TABLE $textTable (key STRING, value STRING) STORED AS 
TEXTFILE")
    +      checkMetastoreRelationStats(textTable, expectedStats = None)
    +      sql(s"INSERT INTO TABLE $textTable SELECT * FROM src")
    +      checkMetastoreRelationStats(textTable, expectedStats = None)
    +
    +      // noscan won't count the number of rows
    +      sql(s"ANALYZE TABLE $textTable COMPUTE STATISTICS noscan")
    +      checkMetastoreRelationStats(textTable, expectedStats =
    +        Some(Statistics(sizeInBytes = 5812, rowCount = None)))
    --- End diff --
    
    This is probably caused by Hive's `hive.exec.compress.output`; try setting 
this to `false`. I do agree with @cloud-fan, that equality testing in these 
cases is very brittle.


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