chore: validate table name (#1146)

Closes #1129
This commit is contained in:
Lei Xu
2024-03-21 14:46:13 -07:00
committed by Weston Pace
parent d32dc84653
commit 473ef7e426
12 changed files with 106 additions and 9 deletions

View File

@@ -521,3 +521,15 @@ def test_prefilter_with_index(tmp_path):
.to_arrow()
)
assert table.num_rows == 1
def test_create_table_with_invalid_names(tmp_path):
db = lancedb.connect(uri=tmp_path)
data = [{"vector": np.random.rand(128), "item": "foo"} for i in range(10)]
with pytest.raises(ValueError):
db.create_table("foo/bar", data)
with pytest.raises(ValueError):
db.create_table("foo bar", data)
with pytest.raises(ValueError):
db.create_table("foo$$bar", data)
db.create_table("foo.bar", data)