William1104 commented on a change in pull request #24221: [SPARK-27248][SQL] `refreshTable` should recreate cache with same cache name and storage level URL: https://github.com/apache/spark/pull/24221#discussion_r284789009
########## File path: sql/hive/src/test/scala/org/apache/spark/sql/hive/CachedTableSuite.scala ########## @@ -361,4 +352,87 @@ class CachedTableSuite extends QueryTest with SQLTestUtils with TestHiveSingleto assert(spark.sharedState.cacheManager.lookupCachedData(samePlan).isDefined) } } + + test("SPARK-27248 refreshTable should recreate cache with same cache name and storage level") { + + // This section tests when a table is cached with its qualified name but its is refreshed with + // its unqualified name. + withTempPath { path => + withTempDatabase { db => + withTable(s"$db.cachedTable") { + withCache(s"$db.cachedTable") { + + // Create table 'cachedTable' in default db for testing purpose. + sql(s"CREATE TABLE $db.cachedTable(key STRING) USING PARQUET LOCATION '${path.toURI}'") Review comment: Hi @dongjoon-hyun, I modified the test further with following assert statements to make sure the test is running against Hive tables. Be honest, I am not sure whether this assert statement is necessary or not. If it is trivial and is not a good idea, I will remove them. ``` val isHive = spark.table(s"$db.cachedTable") .queryExecution .optimizedPlan .collectFirst { case _: HiveTableRelation => true } .getOrElse(false) assert(isHive, s"$db.cachedTable must be a HiveTable") ``` In addition to that, table creation statements are also updated with keyword `USING HIVE` to ``` sql(s"CREATE TABLE $db.cachedTable(id INT, val STRING) USING HIVE") sql("CREATE TABLE cachedTable(id INT, val STRING) USING HIVE") ``` I hope it can make it clear the test is for HIVE tables. Appreciate if you can help to review the PR again when you have time. Many thanks. Best regards, William ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org