This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new f38de637cf [python] Fix cascade drop ignoring tables found during
recheck (#10425)
f38de637cf is described below
commit f38de637cf7feb1cee0e0e09ee8d7da5c76ef713
Author: XiaoHongbo <[email protected]>
AuthorDate: Thu Oct 8 20:43:18 2026 +0800
[python] Fix cascade drop ignoring tables found during recheck (#10425)
---
.../pypaimon/catalog/filesystem_catalog.py | 5 ++++-
.../pypaimon/tests/filesystem_catalog_test.py | 24 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/paimon-python/pypaimon/catalog/filesystem_catalog.py
b/paimon-python/pypaimon/catalog/filesystem_catalog.py
index f2aad5b442..d1264e2f9b 100644
--- a/paimon-python/pypaimon/catalog/filesystem_catalog.py
+++ b/paimon-python/pypaimon/catalog/filesystem_catalog.py
@@ -113,7 +113,10 @@ class FileSystemCatalog(Catalog):
# Check if database still has tables
remaining_tables = self.list_tables(name)
- if remaining_tables and not cascade:
+ if remaining_tables:
+ if cascade:
+ raise OSError(f"Database {name} changed during drop; "
+ f"remaining tables: {remaining_tables}")
raise ValueError(
f"Database {name} is not empty. "
f"Use cascade=True to drop all tables first."
diff --git a/paimon-python/pypaimon/tests/filesystem_catalog_test.py
b/paimon-python/pypaimon/tests/filesystem_catalog_test.py
index 2613b824a9..45ced30f6e 100644
--- a/paimon-python/pypaimon/tests/filesystem_catalog_test.py
+++ b/paimon-python/pypaimon/tests/filesystem_catalog_test.py
@@ -60,6 +60,30 @@ class FileSystemCatalogTest(unittest.TestCase):
database = catalog.get_database("test_db")
self.assertEqual(database.name, "test_db")
+ def test_cascade_drop_preserves_table_created_during_drop(self):
+ catalog = CatalogFactory.create({"warehouse": self.warehouse})
+ catalog.create_database("db", False)
+ schema = Schema(fields=[DataField(0, "value", AtomicType("INT"))])
+ catalog.create_table("db.old", schema, False)
+ delete = catalog.file_io.delete
+ old_path = catalog.get_database_path("db") + "/old"
+
+ def delete_and_create(path, recursive=False):
+ result = delete(path, recursive)
+ if path == old_path:
+ catalog.create_table("db.new", schema, False)
+ return result
+
+ with patch.object(catalog.file_io, "delete",
side_effect=delete_and_create):
+ with self.assertRaisesRegex(OSError, "changed during drop"):
+ catalog.drop_database("db", cascade=True)
+
+ self.assertEqual(["new"], catalog.list_tables("db"))
+ self.assertIsNotNone(catalog.get_table("db.new"))
+ catalog.drop_database("db", cascade=True)
+ with self.assertRaises(DatabaseNotExistException):
+ catalog.get_database("db")
+
def test_table(self):
fields = [
DataField.from_dict({"id": 1, "name": "f0", "type": "INT"}),