You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: table_names() lists table with corrupt/incomplete .lance directory that open_table() cannot open #3127
0.19.0 (also present in current main — listing.rs unchanged)
What happened?
table_names() returns a table name because the .lance directory exists on disk, but open_table() fails with ValueError: Table 'conversations' was not found because the internal dataset files are missing or corrupt.
This happens when a process is interrupted between drop_table() and create_table() (e.g., during a schema migration that does drop+recreate). The result is a .lance directory with no valid manifest inside.
Root cause:ListingDatabase::table_names() (listing.rs:752) does a read_dir + filter for *.lance extensions — pure directory listing, no validation. open_table() → NativeTable::open_with_params → DatasetBuilder::from_uri().load() actually reads the manifest and fails with DatasetNotFound, which becomes TableNotFound → Python ValueError.
Code that uses the common pattern if name in db.table_names(): db.open_table(name) will fail unexpectedly.
Steps to reproduce
importlancedbimportpyarrowaspaimportshutilimportosdb=lancedb.connect("/tmp/lancedb_test")
# Create a table normallyschema=pa.schema([pa.field("id", pa.string())])
db.create_table("test_table", schema=schema)
# Simulate interrupted drop+recreate: remove internal files but keep directorytable_dir="/tmp/lancedb_test/test_table.lance"foriteminos.listdir(table_dir):
item_path=os.path.join(table_dir, item)
ifos.path.isdir(item_path):
shutil.rmtree(item_path)
else:
os.remove(item_path)
# table_names() says it existsprint("test_table"indb.table_names(limit=100)) # True# open_table() disagreesdb.open_table("test_table") # ValueError: Table 'test_table' was not found
Expected behavior
Either:
table_names() should validate that .lance directories contain a loadable dataset (at minimum check for _versions/ or a manifest file), or
open_table() should give a distinct error (e.g., TableCorrupted) rather than TableNotFound, so callers can distinguish "never existed" from "exists but broken" and recover appropriately.
Option 2 is probably better — it's cheap and doesn't add I/O cost to table_names().
Activity
fix: distinguish corrupt table from missing in open_table (lancedb#3731)