Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/2513#discussion_r18325314
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/CachedTableSuite.scala ---
@@ -69,23 +78,50 @@ class CachedTableSuite extends HiveComparisonTest {
test("correct error on uncache of non-cached table") {
intercept[IllegalArgumentException] {
- TestHive.uncacheTable("src")
+ uncacheTable("src")
}
}
test("'CACHE TABLE' and 'UNCACHE TABLE' HiveQL statement") {
- TestHive.sql("CACHE TABLE src")
- TestHive.table("src").queryExecution.executedPlan match {
+ sql("CACHE TABLE src")
+ table("src").queryExecution.executedPlan match {
case _: InMemoryColumnarTableScan => // Found evidence of caching
case _ => fail(s"Table 'src' should be cached")
}
assert(TestHive.isCached("src"), "Table 'src' should be cached")
- TestHive.sql("UNCACHE TABLE src")
- TestHive.table("src").queryExecution.executedPlan match {
+ sql("UNCACHE TABLE src")
+ table("src").queryExecution.executedPlan match {
case _: InMemoryColumnarTableScan => fail(s"Table 'src' should not
be cached")
case _ => // Found evidence of uncaching
}
- assert(!TestHive.isCached("src"), "Table 'src' should not be cached")
+ assert(!isCached("src"), "Table 'src' should not be cached")
+ }
+
+ test("CACHE TABLE tableName AS SELECT * FROM anotherTable") {
+ sql("CACHE TABLE testCacheTable AS SELECT * FROM src")
+ assert(isCached("testCacheTable"), "Table 'testCacheTable' should be
cached")
+ assert(
+ isMaterialized("testCacheTable"),
+ "Eagerly cached in-memory table should have already been
materialized")
+ uncacheTable("testCacheTable")
+ }
+
+ test("CACHE TABLE tableName AS SELECT ...") {
+ sql("CACHE TABLE testCacheTable AS SELECT key FROM src LIMIT 10")
+ assert(isCached("testCacheTable"), "Table 'testCacheTable' should be
cached")
+ assert(
+ isMaterialized("testCacheTable"),
+ "Eagerly cached in-memory table should have already been
materialized")
+ uncacheTable("testCacheTable")
+ }
+
+ test("LAZY CACHE TABLE tableName") {
--- End diff --
Agree, I wasn't very sure about the syntax either when add this.
---
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]