Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/14712#discussion_r75548186
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala ---
@@ -168,6 +170,57 @@ class StatisticsSuite extends QueryTest with
TestHiveSingleton with SQLTestUtils
TableIdentifier("tempTable"), ignoreIfNotExists = true, purge =
false)
}
+ test("generate table-level statistics") {
+ def checkTableStats(
+ statsSeq: Seq[Statistics],
+ sizeInBytes: Int,
+ estimatedSize: Int,
+ rowCount: Int): Unit = {
+ assert(statsSeq.size === 1)
+ assert(statsSeq.head.sizeInBytes === BigInt(sizeInBytes))
+ assert(statsSeq.head.estimatedSize === Some(BigInt(estimatedSize)))
+ assert(statsSeq.head.rowCount === Some(BigInt(rowCount)))
+ }
+
+ sql("CREATE TABLE analyzeTable (key STRING, value STRING)").collect()
+ sql("CREATE TABLE parquetTable (key STRING, value STRING) STORED AS
PARQUET").collect()
+ sql("CREATE TABLE orcTable (key STRING, value STRING) STORED AS
ORC").collect()
+
+ sql("INSERT INTO TABLE analyzeTable SELECT * FROM src").collect()
+ sql("INSERT INTO TABLE parquetTable SELECT * FROM src").collect()
+ sql("INSERT INTO TABLE orcTable SELECT * FROM src").collect()
+ sql("INSERT INTO TABLE orcTable SELECT * FROM src").collect()
+
+ sql("ANALYZE TABLE analyzeTable COMPUTE STATISTICS")
--- End diff --
Before calling `ANALYZE TABLE`, table properties already have the latest
values of `numFiles` and `totalSize`. Thus, `totalSize` is not added/updated by
`ANALYZE TABLE`.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]