amaliujia commented on code in PR #36983:
URL: https://github.com/apache/spark/pull/36983#discussion_r907838349


##########
sql/core/src/test/scala/org/apache/spark/sql/internal/CatalogSuite.scala:
##########
@@ -749,4 +749,22 @@ class CatalogSuite extends SharedSparkSession with 
AnalysisTest with BeforeAndAf
     assert(spark.catalog.currentCatalog().equals("spark_catalog"))
     assert(spark.catalog.listCatalogs().collect().map(c => c.name).toSet == 
Set("testcat"))
   }
+
+  test("SPARK-39583: Make RefreshTable be compatible with 3 layer namespace") {
+    val catalogName = "testcat"
+    val dbName = "default"
+    val tableName = "my_table"
+    val tableSchema = new StructType().add("i", "int")
+    val description = "this is a test table"
+    val fullTableName = "testcat.default.my_table"
+
+    createTable(tableName, dbName, catalogName, 
classOf[FakeV2Provider].getName, tableSchema,
+      Map.empty[String, String], description)
+    spark.catalog.refreshTable(fullTableName)
+    assert(!spark.catalog.isCached(fullTableName))
+
+    spark.catalog.cacheTable(fullTableName)
+    spark.catalog.refreshTable(fullTableName)
+    assert(spark.catalog.isCached(fullTableName))

Review Comment:
   ```
       spark.range(10).write.saveAsTable(tableName)
       spark.catalog.cacheTable(tableName)
       assert(spark.table(tableName).collect().length == 10)
   
       spark.range(5).write.mode(SaveMode.Overwrite)
         .saveAsTable(tableName)
       assert(spark.table(tableName).collect().length == 10)
       spark.catalog.refresh(tableName)
       assert(spark.table(tableName).collect().length == 5)
   ```
   
   I am doing this but I found `spark.catalog.cacheTable(tableName)` does not 
take effect as I expect? I expect it will return length == 10 because of the 
cache. However the second `assert(spark.table(tableName).collect().length == 
10)` will just fail to say the test contains 5 rows?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to