Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/15189#discussion_r80406877
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/InMemoryColumnarQuerySuite.scala
---
@@ -232,4 +232,29 @@ class InMemoryColumnarQuerySuite extends QueryTest
with SharedSQLContext {
val columnTypes2 = List.fill(length2)(IntegerType)
val columnarIterator2 = GenerateColumnAccessor.generate(columnTypes2)
}
+
+ test("SPARK-17549: cached table size should be correctly calculated") {
+ val data = spark.sparkContext.parallelize(1 to 10, 5).map { i => (i,
i.toLong) }
+ .toDF("col1", "col2")
+ val plan = spark.sessionState.executePlan(data.logicalPlan).sparkPlan
+ val cached = InMemoryRelation(true, 5, MEMORY_ONLY, plan, None)
+
+ // Materialize the data.
+ val expectedAnswer = data.collect()
+ checkAnswer(cached, expectedAnswer)
+
+ // Check that the right size was calculated.
+ val expectedColSizes = expectedAnswer.size * (INT.defaultSize +
LONG.defaultSize)
+ assert(cached.statistics.sizeInBytes === expectedColSizes)
+
+ // Create a projection of the cached data and make sure the statistics
are correct.
+ val projected = cached.withOutput(Seq(plan.output.last))
+ assert(projected.statistics.sizeInBytes === expectedAnswer.size *
LONG.defaultSize)
--- End diff --
I am not sure if I understand the last two parts. After we cache the
dataset, I am not sure if we can change the number of output columns (this
test) or the data types (the next one).
If we do a project on the cached dataset, we will see a project operator on
top of the InMemoryRelation.
I am wondering what kinds of queries can cause this problems?
---
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]