Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/9889#discussion_r45824320
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
---
@@ -213,6 +215,56 @@ class DatasetSuite extends QueryTest with
SharedSQLContext {
}
+ test("persist and unpersist") {
+ val ds = Seq(("a", 1) , ("b", 2), ("c", 3)).toDS().select(expr("_2 +
1").as[Int])
+ val cached = ds.cache()
+ // count triggers the caching action. It should not throw.
+ cached.count()
+ // Make sure, the Dataset is indeed cached.
+ assert(sqlContext.cacheManager.lookupCachedData(cached).nonEmpty)
+ assertResult(1, "InMemoryRelation not found, testData should have been
cached") {
+ cached.queryExecution.withCachedData.collect {
+ case r: InMemoryRelation => r
+ }.size
+ }
+ // Check result.
+ checkAnswer(
+ cached,
+ 2, 3, 4)
+ // Drop the cache.
+ cached.unpersist()
+ }
+
+ test("persist and then rebind right encoder when join 2 datasets") {
+ val ds1 = Seq("1", "2").toDS().as("a")
+ val ds2 = Seq(2, 3).toDS().as("b")
+
+ ds1.persist()
+ ds2.persist()
+
+ val joined = ds1.joinWith(ds2, $"a.value" === $"b.value")
+ checkAnswer(joined, ("2", 2))
--- End diff --
We should `assertCached` in every test that checks caching.
---
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]