You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by dongjoon-hyun <gi...@git.apache.org> on 2018/10/14 02:39:38 UTC
[GitHub] spark pull request #22263: [SPARK-25269][SQL] SQL interface support specify ...
Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/22263#discussion_r224977190
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala ---
@@ -288,6 +297,68 @@ class CachedTableSuite extends QueryTest with SQLTestUtils with SharedSQLContext
}
}
+ test("SQL interface support storageLevel(DISK_ONLY)") {
+ sql("CACHE TABLE testData OPTIONS('storageLevel' 'DISK_ONLY')")
+ assertCached(spark.table("testData"))
+ val rddId = rddIdOf("testData")
+ assert(isExpectStorageLevel(rddId, Disk))
+ assert(!isExpectStorageLevel(rddId, Memory))
+ spark.catalog.uncacheTable("testData")
+ }
+
+ test("SQL interface select from table support storageLevel(DISK_ONLY)") {
+ sql("CACHE TABLE testSelect OPTIONS('storageLevel' 'DISK_ONLY') select * from testData")
+ assertCached(spark.table("testSelect"))
+ val rddId = rddIdOf("testSelect")
+ assert(isExpectStorageLevel(rddId, Disk))
+ assert(!isExpectStorageLevel(rddId, Memory))
+ spark.catalog.uncacheTable("testSelect")
+ }
+
+ test("SQL interface support storageLevel(DISK_ONLY) with invalid options") {
+ sql("CACHE TABLE testData OPTIONS('storageLevel' 'DISK_ONLY', 'a' '1', 'b' '2')")
+ assertCached(spark.table("testData"))
+ val rddId = rddIdOf("testData")
+ assert(isExpectStorageLevel(rddId, Disk))
+ assert(!isExpectStorageLevel(rddId, Memory))
+ spark.catalog.uncacheTable("testData")
+ }
+
+ test("SQL interface support storageLevel(MEMORY_ONLY)") {
+ sql("CACHE TABLE testData OPTIONS('storageLevel' 'MEMORY_ONLY')")
+ assertCached(spark.table("testData"))
+ val rddId = rddIdOf("testData")
+ assert(!isExpectStorageLevel(rddId, Disk))
+ assert(isExpectStorageLevel(rddId, Memory))
+ }
+
+ test("SQL interface support storageLevel(Invalid StorageLevel)") {
+ val message = intercept[IllegalArgumentException] {
+ sql("CACHE TABLE testData OPTIONS('storageLevel' 'invalid_storage_level')")
+ }.getMessage
+ assert(message.contains("Invalid StorageLevel: INVALID_STORAGE_LEVEL"))
+ }
+
+ test("SQL interface support storageLevel(with LAZY)") {
+ sql("CACHE LAZY TABLE testData OPTIONS('storageLevel' 'disk_only')")
+ assertCached(spark.table("testData"))
+
+ val rddId = rddIdOf("testData")
+ assert(
+ !isMaterialized(rddId),
+ "Lazily cached in-memory table shouldn't be materialized eagerly")
+
+ sql("SELECT COUNT(*) FROM testData").collect()
+ assert(
+ isMaterialized(rddId),
+ "Lazily cached in-memory table should have been materialized")
+
--- End diff --
We didn't check the storage level in this test case.
Add `isExpectStorageLevel` here?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org