This is an automated email from the ASF dual-hosted git repository.

gengliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new fd683ce6dbd3 [SPARK-53924][FOLLOWUP][TESTS] Add tests for cached temp 
view detecting schema changes
fd683ce6dbd3 is described below

commit fd683ce6dbd3eb376fb3618dba55e711606876c1
Author: Gengliang Wang <[email protected]>
AuthorDate: Mon Nov 17 22:08:53 2025 -0800

    [SPARK-53924][FOLLOWUP][TESTS] Add tests for cached temp view detecting 
schema changes
    
    ### What changes were proposed in this pull request?
    
    Follow-up of https://github.com/apache/spark/pull/52876, add tests for 
cached temp view detecting schema changes
    
    ### Why are the changes needed?
    
    There is no test coverage after comment 
https://github.com/apache/spark/pull/52876#discussion_r2529313684 is addressed. 
This PR is to add a test case for it.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    New test case
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #53103 from gengliangwang/SPARK-53924-test.
    
    Authored-by: Gengliang Wang <[email protected]>
    Signed-off-by: Gengliang Wang <[email protected]>
---
 .../sql/connector/DataSourceV2DataFrameSuite.scala | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala
index c59e624cb178..d802a9a7d75f 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala
@@ -1173,6 +1173,34 @@ class DataSourceV2DataFrameSuite
     }
   }
 
+  test("SPARK-54157: cached temp view detects schema changes after analysis") {
+    val t = "testcat.ns1.ns2.tbl"
+    withTable(t) {
+      sql(s"CREATE TABLE $t (id INT, data STRING) USING foo")
+      sql(s"INSERT INTO $t VALUES (1, 'a')")
+
+      // create a temp view on top of the DSv2 table and cache the view
+      spark.table(t).createOrReplaceTempView("v")
+      sql("CACHE TABLE v")
+      assertCached(sql("SELECT * FROM v"))
+
+      // change table schema after the view has been analyzed and cached
+      sql(s"ALTER TABLE $t ADD COLUMN extra INT")
+
+      // execution should fail with column mismatch even though the view is 
cached
+      checkError(
+        exception = intercept[AnalysisException] { spark.table("v").collect() 
},
+        condition = 
"INCOMPATIBLE_COLUMN_CHANGES_AFTER_VIEW_WITH_PLAN_CREATION",
+        parameters = Map(
+          "viewName" -> "`v`",
+          "tableName" -> "`testcat`.`ns1`.`ns2`.`tbl`",
+          "colType" -> "data",
+          "errors" ->
+            """
+              |- `extra` INT has been added""".stripMargin))
+    }
+  }
+
   test("SPARK-54157: detect nested struct field changes after DataFrame 
analysis") {
     val t = "testcat.ns1.ns2.tbl"
     withTable(t) {


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

Reply via email to