Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/18804#discussion_r131190694
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala ---
@@ -117,6 +125,72 @@ class StatisticsSuite extends
StatisticsCollectionTestBase with TestHiveSingleto
}
}
+ test("analyze non hive compatible datasource tables") {
+ val table = "parquet_tab"
+ withTable(table) {
+ sql(
+ s"""
+ |CREATE TABLE $table (a int, b int)
+ |USING parquet
+ |OPTIONS (skipHiveMetadata true)
+ """.stripMargin)
+
+ // Verify that the schema stored in catalog is a dummy one used for
+ // data source tables. The actual schema is stored in table
properties.
+ val rawSchema = dropMetadata(hiveClient.getTable("default",
table).schema)
+ val expectedRawSchema = new StructType()
+ .add("col", "array<string>")
+ assert(rawSchema == expectedRawSchema)
+
+ val actualSchema =
spark.sharedState.externalCatalog.getTable("default", table).schema
+ val expectedActualSchema = new StructType()
+ .add("a", "int")
+ .add("b", "int")
+ assert(actualSchema == expectedActualSchema)
+
+ sql(s"INSERT INTO $table VALUES (1, 1)")
+ sql(s"INSERT INTO $table VALUES (2, 1)")
+ sql(s"ANALYZE TABLE $table COMPUTE STATISTICS FOR COLUMNS a, b")
+ val fetchedStats0 =
+ checkTableStats(table, hasSizeInBytes = true, expectedRowCounts =
Some(2))
+ assert(fetchedStats0.get.colStats == Map(
+ "a" -> ColumnStat(2, Some(1), Some(2), 0, 4, 4),
+ "b" -> ColumnStat(1, Some(1), Some(1), 0, 4, 4)))
+ }
+ }
+
+ test("Analyze hive serde tables when schema is not same as schema in
table properties") {
+
--- End diff --
Nit: This line is useless.
---
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]