mattfaltyn commented on code in PR #3062:
URL: https://github.com/apache/iceberg-rust/pull/3062#discussion_r3860777689


##########
crates/catalog/sql/src/catalog.rs:
##########
@@ -1386,6 +1389,70 @@ mod tests {
         new_sql_catalog(warehouse_loc.clone(), Some("iceberg")).await;
     }
 
+    #[tokio::test]
+    async fn test_execute_returns_commit_error() {
+        let sql_lite_uri = format!("sqlite:{}", temp_path());
+        sqlx::Sqlite::create_database(&sql_lite_uri).await.unwrap();
+        let catalog = SqlCatalogBuilder::default()
+            .with_storage_factory(Arc::new(LocalFsStorageFactory))
+            .prop("pool.max-connections", "1")
+            .load(
+                "iceberg",
+                HashMap::from_iter([
+                    (SQL_CATALOG_PROP_URI.to_string(), sql_lite_uri),
+                    (SQL_CATALOG_PROP_WAREHOUSE.to_string(), temp_path()),
+                ]),
+            )
+            .await
+            .unwrap();
+
+        catalog
+            .connection
+            .execute("PRAGMA foreign_keys = ON")
+            .await
+            .unwrap();
+        catalog
+            .connection
+            .execute("CREATE TABLE parent(id INTEGER PRIMARY KEY)")
+            .await
+            .unwrap();
+        catalog
+            .connection
+            .execute(
+                "CREATE TABLE child(parent_id INTEGER REFERENCES parent(id) \
+                 DEFERRABLE INITIALLY DEFERRED)",
+            )
+            .await
+            .unwrap();
+
+        assert!(
+            catalog
+                .execute("INSERT INTO child VALUES (1)", vec![], None)
+                .await
+                .is_err()
+        );
+        let child_count: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM child")
+            .fetch_one(&catalog.connection)
+            .await
+            .unwrap();
+        assert_eq!(child_count, 0);
+
+        catalog
+            .connection
+            .execute("INSERT INTO parent VALUES (1)")
+            .await
+            .unwrap();
+        catalog
+            .execute("INSERT INTO child VALUES (1)", vec![], None)
+            .await
+            .unwrap();
+        let child_count: i64 = sqlx::query_scalar("SELECT COUNT(*) FROM child")
+            .fetch_one(&catalog.connection)
+            .await
+            .unwrap();
+        assert_eq!(child_count, 1);
+    }

Review Comment:
   Good point—thanks! The regression now sets up the deferred failure 
internally, invokes public `create_namespace`, asserts the propagated error, 
and verifies rollback through public `namespace_exists`.



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