mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-31 02:18:27 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f54f5600ad | |||
| e34fe84c7f | |||
| 5b1f248257 | |||
| 95e34d47b9 | |||
| a0defd448f | |||
| 0fadb65153 | |||
| 15fbcf61fc |
@@ -1,5 +1,5 @@
|
|||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "0.31.0-beta.8"
|
current_version = "0.31.0-beta.7"
|
||||||
parse = """(?x)
|
parse = """(?x)
|
||||||
(?P<major>0|[1-9]\\d*)\\.
|
(?P<major>0|[1-9]\\d*)\\.
|
||||||
(?P<minor>0|[1-9]\\d*)\\.
|
(?P<minor>0|[1-9]\\d*)\\.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "lancedb-python"
|
name = "lancedb-python"
|
||||||
version = "0.31.0-beta.8"
|
version = "0.31.0-beta.7"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description = "Python bindings for LanceDB"
|
description = "Python bindings for LanceDB"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ use crate::connection::NamespaceClientPushdownOperation;
|
|||||||
use crate::database::ReadConsistency;
|
use crate::database::ReadConsistency;
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::table::NativeTable;
|
use crate::table::NativeTable;
|
||||||
use lance::dataset::WriteMode;
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
BaseTable, CloneTableRequest, CreateTableMode, CreateTableRequest as DbCreateTableRequest,
|
BaseTable, CloneTableRequest, CreateTableMode, CreateTableRequest as DbCreateTableRequest,
|
||||||
@@ -185,7 +184,6 @@ impl Database for LanceNamespaceDatabase {
|
|||||||
async fn create_table(&self, request: DbCreateTableRequest) -> Result<Arc<dyn BaseTable>> {
|
async fn create_table(&self, request: DbCreateTableRequest) -> Result<Arc<dyn BaseTable>> {
|
||||||
let mut table_id = request.namespace_path.clone();
|
let mut table_id = request.namespace_path.clone();
|
||||||
table_id.push(request.name.clone());
|
table_id.push(request.name.clone());
|
||||||
let mut existing_table = None;
|
|
||||||
|
|
||||||
match request.mode {
|
match request.mode {
|
||||||
CreateTableMode::Create => {}
|
CreateTableMode::Create => {}
|
||||||
@@ -194,7 +192,20 @@ impl Database for LanceNamespaceDatabase {
|
|||||||
id: Some(table_id.clone()),
|
id: Some(table_id.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
existing_table = self.namespace.describe_table(describe_request).await.ok();
|
let describe_result = self.namespace.describe_table(describe_request).await;
|
||||||
|
if describe_result.is_ok() {
|
||||||
|
// Drop the existing table - must succeed
|
||||||
|
let drop_request = DropTableRequest {
|
||||||
|
id: Some(table_id.clone()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
self.namespace
|
||||||
|
.drop_table(drop_request)
|
||||||
|
.await
|
||||||
|
.map_err(|e| Error::Runtime {
|
||||||
|
message: format!("Failed to drop existing table for overwrite: {}", e),
|
||||||
|
})?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CreateTableMode::ExistOk(_) => {
|
CreateTableMode::ExistOk(_) => {
|
||||||
let describe_request = DescribeTableRequest {
|
let describe_request = DescribeTableRequest {
|
||||||
@@ -229,55 +240,40 @@ impl Database for LanceNamespaceDatabase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (location, initial_storage_options, managed_versioning) = {
|
let (location, initial_storage_options, managed_versioning) = {
|
||||||
if let Some(response) = existing_table {
|
let response = self
|
||||||
let loc = response.location.ok_or_else(|| Error::Runtime {
|
.namespace
|
||||||
message: "Table location is missing from describe_table response".to_string(),
|
.declare_table(declare_request)
|
||||||
})?;
|
.await
|
||||||
let opts = response
|
.map_err(|e| {
|
||||||
.storage_options
|
let err_str = e.to_string();
|
||||||
.or_else(|| Some(self.storage_options.clone()))
|
if matches!(request.mode, CreateTableMode::Create)
|
||||||
.filter(|o| !o.is_empty());
|
&& (err_str.contains("already exists")
|
||||||
(loc, opts, response.managed_versioning)
|
|| err_str.contains("TableAlreadyExists")
|
||||||
} else {
|
|| err_str.contains("table already exists"))
|
||||||
let response = self
|
{
|
||||||
.namespace
|
Error::TableAlreadyExists {
|
||||||
.declare_table(declare_request)
|
name: request.name.clone(),
|
||||||
.await
|
|
||||||
.map_err(|e| {
|
|
||||||
let err_str = e.to_string();
|
|
||||||
if matches!(request.mode, CreateTableMode::Create)
|
|
||||||
&& (err_str.contains("already exists")
|
|
||||||
|| err_str.contains("TableAlreadyExists")
|
|
||||||
|| err_str.contains("table already exists"))
|
|
||||||
{
|
|
||||||
Error::TableAlreadyExists {
|
|
||||||
name: request.name.clone(),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Error::Runtime {
|
|
||||||
message: format!("Failed to declare table: {}", e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})?;
|
} else {
|
||||||
let loc = response.location.ok_or_else(|| Error::Runtime {
|
Error::Runtime {
|
||||||
message: "Table location is missing from declare_table response".to_string(),
|
message: format!("Failed to declare table: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
})?;
|
})?;
|
||||||
// Use storage options from response, fall back to self.storage_options
|
let loc = response.location.ok_or_else(|| Error::Runtime {
|
||||||
let opts = response
|
message: "Table location is missing from declare_table response".to_string(),
|
||||||
.storage_options
|
})?;
|
||||||
.or_else(|| Some(self.storage_options.clone()))
|
// Use storage options from response, fall back to self.storage_options
|
||||||
.filter(|o| !o.is_empty());
|
let opts = response
|
||||||
(loc, opts, response.managed_versioning)
|
.storage_options
|
||||||
}
|
.or_else(|| Some(self.storage_options.clone()))
|
||||||
|
.filter(|o| !o.is_empty());
|
||||||
|
(loc, opts, response.managed_versioning)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build write params with storage options and commit handler
|
// Build write params with storage options and commit handler
|
||||||
let mut params = request.write_options.lance_write_params.unwrap_or_default();
|
let mut params = request.write_options.lance_write_params.unwrap_or_default();
|
||||||
|
|
||||||
if matches!(request.mode, CreateTableMode::Overwrite) {
|
|
||||||
params.mode = WriteMode::Overwrite;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up storage options if provided
|
// Set up storage options if provided
|
||||||
if let Some(storage_opts) = initial_storage_options {
|
if let Some(storage_opts) = initial_storage_options {
|
||||||
let store_params = params
|
let store_params = params
|
||||||
|
|||||||
Reference in New Issue
Block a user