mirror of
https://github.com/lancedb/lancedb.git
synced 2026-05-18 04:20:39 +00:00
fix: don't use v2 by default on empty table (#1469)
This commit is contained in:
@@ -552,6 +552,12 @@ async def test_create_in_v2_mode(tmp_path):
|
||||
|
||||
assert await is_in_v2_mode(tbl)
|
||||
|
||||
# Create empty table uses v1 mode by default
|
||||
tbl = await db.create_table("test_empty_v2_default", data=None, schema=schema)
|
||||
await tbl.add(make_table())
|
||||
|
||||
assert not await is_in_v2_mode(tbl)
|
||||
|
||||
|
||||
def test_replace_index(tmp_path):
|
||||
db = lancedb.connect(uri=tmp_path)
|
||||
|
||||
@@ -220,7 +220,7 @@ impl CreateTableBuilder<false, NoData> {
|
||||
mode: CreateTableMode::default(),
|
||||
write_options: WriteOptions::default(),
|
||||
embeddings: Vec::new(),
|
||||
use_legacy_format: false,
|
||||
use_legacy_format: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1079,7 +1079,10 @@ impl NativeTable {
|
||||
params: Option<WriteParams>,
|
||||
read_consistency_interval: Option<std::time::Duration>,
|
||||
) -> Result<Self> {
|
||||
let params = params.unwrap_or_default();
|
||||
let params = params.unwrap_or(WriteParams {
|
||||
use_legacy_format: true,
|
||||
..Default::default()
|
||||
});
|
||||
// patch the params if we have a write store wrapper
|
||||
let params = match write_store_wrapper.clone() {
|
||||
Some(wrapper) => params.patch_with_store_wrapper(wrapper)?,
|
||||
@@ -1625,11 +1628,16 @@ impl TableInternal for NativeTable {
|
||||
}
|
||||
|
||||
// patch the params if we have a write store wrapper
|
||||
let lance_params = match self.store_wrapper.clone() {
|
||||
let mut lance_params = match self.store_wrapper.clone() {
|
||||
Some(wrapper) => lance_params.patch_with_store_wrapper(wrapper)?,
|
||||
None => lance_params,
|
||||
};
|
||||
|
||||
// Only use the new format if the user passes use_legacy_format=False in while creating
|
||||
// a table with data. We don't want to accidentally switch to v2 format during an add
|
||||
// operation. If the table is already v2 this won't have any effect.
|
||||
lance_params.use_legacy_format = true;
|
||||
|
||||
self.dataset.ensure_mutable().await?;
|
||||
let dataset = Dataset::write(data, &self.uri, Some(lance_params)).await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user