Github user wzhfy commented on a diff in the pull request: https://github.com/apache/spark/pull/15090#discussion_r79441079 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/StatisticsSuite.scala --- @@ -101,4 +101,47 @@ class StatisticsSuite extends QueryTest with SharedSQLContext { checkTableStats(tableName, expectedRowCount = Some(2)) } } + + test("test column-level statistics for data source table created in InMemoryCatalog") { + def checkColStats(colStats: BasicColStats, expectedColStats: BasicColStats): Unit = { + assert(colStats.dataType == expectedColStats.dataType) + assert(colStats.numNulls == expectedColStats.numNulls) + assert(colStats.max == expectedColStats.max) + assert(colStats.min == expectedColStats.min) + if (expectedColStats.ndv.isDefined) { + // ndv is an approximate value, so we just make sure we have the value + assert(colStats.ndv.get >= 0) --- End diff -- I think I may know what @hvanhovell meant. The standard deviation is the parameter we pass to HyperLogLogPlusPlus, so the code may look like this: ``` // ndv is an approximate value, so we make sure we have the value, and it should be // within 3*SD's of the given rsd. assert(colStats.ndv.get >= 0) val rsd = spark.sessionState.conf.ndvMaxError val error = math.abs((colStats.ndv.get / expectedColStats.ndv.get.toDouble) - 1.0d) assert(error <= rsd * 3.0d, "Error should be within 3 std. errors.") ``` What do you think?
--- 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