Skip to content

Commit d356ae3

Browse files
author
Marcelo Vanzin
committed
Add unit test for table size stat.
1 parent ede3548 commit d356ae3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sql/core/src/test/scala/org/apache/spark/sql/execution/columnar/InMemoryColumnarQuerySuite.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,18 @@ class InMemoryColumnarQuerySuite extends QueryTest with SharedSQLContext {
232232
val columnTypes2 = List.fill(length2)(IntegerType)
233233
val columnarIterator2 = GenerateColumnAccessor.generate(columnTypes2)
234234
}
235+
236+
test("SPARK-17549: cached table size should be correctly calculated") {
237+
val data = spark.sparkContext.parallelize(1 to 10, 5).toDF()
238+
val plan = spark.sessionState.executePlan(data.logicalPlan).sparkPlan
239+
val cached = InMemoryRelation(true, 5, MEMORY_ONLY, plan, None)
240+
241+
// Materialize the data.
242+
val expectedAnswer = data.collect()
243+
checkAnswer(cached, expectedAnswer)
244+
245+
// Check that the right size was calculated.
246+
assert(cached.batchStats.value === expectedAnswer.size * INT.defaultSize)
247+
}
248+
235249
}

0 commit comments

Comments
 (0)