Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/15959#discussion_r89264465
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala ---
@@ -310,6 +270,110 @@ class StatisticsSuite extends QueryTest with
TestHiveSingleton with SQLTestUtils
}
}
+ test("verify serialized column stats after analyzing columns") {
+ import testImplicits._
+
+ val tableName = "column_stats_test2"
+ // (data.head.productArity - 1) because the last column does not
support stats collection.
+ assert(stats.size == data.head.productArity - 1)
+ val df = data.toDF(stats.keys.toSeq :+ "carray" : _*)
+
+ withTable(tableName) {
+ df.write.saveAsTable(tableName)
+
+ // Collect statistics
+ sql(s"analyze table $tableName compute STATISTICS FOR COLUMNS " +
stats.keys.mkString(", "))
+
+ // Validate statistics
+ val hiveClient =
spark.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
+ val table = hiveClient.getTable("default", tableName)
+
+ val props =
table.properties.filterKeys(_.startsWith("spark.sql.statistics.colStats"))
+ assert(props == Map(
--- End diff --
cc @cloud-fan / @wzhfy
This is a very explicit test for the serialization protocol.
---
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]