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

JingsongLi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 79909087 fix(datafusion): reject UPDATE and DELETE on temporary 
targets (#1325)
79909087 is described below

commit 799090872d0ebdcf7d37d36e403db904e3a99f0b
Author: slfan1989 <[email protected]>
AuthorDate: Thu Nov 5 19:00:20 2026 +0800

    fix(datafusion): reject UPDATE and DELETE on temporary targets (#1325)
---
 crates/integrations/datafusion/src/sql_context.rs  | 10 +++++
 .../datafusion/tests/sql_context_tests.rs          | 48 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/crates/integrations/datafusion/src/sql_context.rs 
b/crates/integrations/datafusion/src/sql_context.rs
index 99b92af7..88d45004 100644
--- a/crates/integrations/datafusion/src/sql_context.rs
+++ b/crates/integrations/datafusion/src/sql_context.rs
@@ -1881,6 +1881,11 @@ impl SQLContext {
             }
         };
         Self::ensure_main_branch_write_target(&table_name, "UPDATE")?;
+        if self.temp_table_for(&table_name).await?.is_some() {
+            return Err(DataFusionError::NotImplemented(
+                "UPDATE on temporary tables or views is not supported".into(),
+            ));
+        }
         let (catalog, _catalog_name, identifier) = 
self.resolve_catalog_and_table(&table_name)?;
 
         let table = catalog
@@ -1909,6 +1914,11 @@ impl SQLContext {
             }
         };
         Self::ensure_main_branch_write_target(&table_name, "DELETE")?;
+        if self.temp_table_for(&table_name).await?.is_some() {
+            return Err(DataFusionError::NotImplemented(
+                "DELETE on temporary tables or views is not supported".into(),
+            ));
+        }
         let (catalog, _catalog_name, identifier) = 
self.resolve_catalog_and_table(&table_name)?;
 
         let table = catalog
diff --git a/crates/integrations/datafusion/tests/sql_context_tests.rs 
b/crates/integrations/datafusion/tests/sql_context_tests.rs
index 8ff8fed6..f5ac4fe1 100644
--- a/crates/integrations/datafusion/tests/sql_context_tests.rs
+++ b/crates/integrations/datafusion/tests/sql_context_tests.rs
@@ -1028,6 +1028,54 @@ async fn 
test_scoped_show_accepts_temp_only_database_and_shadowing() {
     );
 }
 
+#[tokio::test]
+async fn test_update_and_delete_reject_shadowed_temporary_targets() {
+    let (_tmp, catalog) = create_test_env();
+    let ctx = create_sql_context(catalog).await;
+    ctx.sql("CREATE TABLE default.shadowed (id INT)")
+        .await
+        .unwrap();
+    ctx.sql("INSERT INTO default.shadowed VALUES (1), (2)")
+        .await
+        .unwrap()
+        .collect()
+        .await
+        .unwrap();
+
+    for kind in ["TABLE", "VIEW"] {
+        ctx.sql(&format!(
+            "CREATE TEMPORARY {kind} default.shadowed AS SELECT CAST(999 AS 
INT) AS id"
+        ))
+        .await
+        .unwrap();
+        assert_eq!(
+            collect_ids(&ctx, "SELECT id FROM shadowed").await,
+            vec![999]
+        );
+
+        assert_sql_error_contains(
+            &ctx,
+            "UPDATE shadowed SET id = 10 WHERE id = 1",
+            "UPDATE on temporary tables or views is not supported",
+        )
+        .await;
+        assert_sql_error_contains(
+            &ctx,
+            "DELETE FROM paimon.default.shadowed WHERE id = 2",
+            "DELETE on temporary tables or views is not supported",
+        )
+        .await;
+
+        ctx.sql(&format!("DROP TEMPORARY {kind} default.shadowed"))
+            .await
+            .unwrap();
+        assert_eq!(
+            collect_ids(&ctx, "SELECT id FROM shadowed ORDER BY id").await,
+            vec![1, 2]
+        );
+    }
+}
+
 #[tokio::test]
 async fn test_scoped_show_accepts_information_schema() {
     let (_tmp, catalog) = create_test_env();

Reply via email to