mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-09 21:32:58 +00:00
fix: delete tables from DDB on drop_all_tables (#2194)
Prior to this commit, issuing drop_all_tables on a listing database with an external manifest store would delete physical tables but leave references behind in the manifest store. The table drop would succeed, but subsequent creation of a table with the same name would fail with a conflict. With this patch, the external manifest store is updated to account for the dropped tables so that dropped table names can be reused.
This commit is contained in:
@@ -34,3 +34,7 @@ doctest: ## Run documentation tests.
|
||||
.PHONY: test
|
||||
test: ## Run tests.
|
||||
pytest python/tests -vv --durations=10 -m "not slow and not s3_test"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf data
|
||||
|
||||
@@ -252,3 +252,27 @@ def test_s3_dynamodb_sync(s3_bucket: str, commit_table: str, monkeypatch):
|
||||
db.drop_table("test_ddb_sync")
|
||||
assert db.table_names() == []
|
||||
db.drop_database()
|
||||
|
||||
|
||||
@pytest.mark.s3_test
|
||||
def test_s3_dynamodb_drop_all_tables(s3_bucket: str, commit_table: str, monkeypatch):
|
||||
for key, value in CONFIG.items():
|
||||
monkeypatch.setenv(key.upper(), value)
|
||||
|
||||
uri = f"s3+ddb://{s3_bucket}/test2?ddbTableName={commit_table}"
|
||||
db = lancedb.connect(uri, read_consistency_interval=timedelta(0))
|
||||
data = pa.table({"x": ["a", "b", "c"]})
|
||||
|
||||
db.create_table("foo", data)
|
||||
db.create_table("bar", data)
|
||||
assert db.table_names() == ["bar", "foo"]
|
||||
|
||||
# dropping all tables should clear multiple tables
|
||||
db.drop_all_tables()
|
||||
assert db.table_names() == []
|
||||
|
||||
# create a new table with the same name to ensure DDB is clean
|
||||
db.create_table("foo", data)
|
||||
assert db.table_names() == ["foo"]
|
||||
|
||||
db.drop_all_tables()
|
||||
|
||||
Reference in New Issue
Block a user