diff --git a/rust/lancedb/src/database/listing.rs b/rust/lancedb/src/database/listing.rs index 8aa9e437..13b84f5f 100644 --- a/rust/lancedb/src/database/listing.rs +++ b/rust/lancedb/src/database/listing.rs @@ -13,10 +13,10 @@ use lance_datafusion::utils::StreamingWriteSource; use lance_encoding::version::LanceFileVersion; use lance_table::io::commit::commit_handler_from_url; use object_store::local::LocalFileSystem; -use snafu::{OptionExt, ResultExt}; +use snafu::ResultExt; use crate::connection::ConnectRequest; -use crate::error::{CreateDirSnafu, Error, InvalidTableNameSnafu, Result}; +use crate::error::{CreateDirSnafu, Error, Result}; use crate::io::object_store::MirroringObjectStoreWrapper; use crate::table::NativeTable; use crate::utils::validate_table_name; @@ -411,17 +411,13 @@ impl ListingDatabase { fn table_uri(&self, name: &str) -> Result { validate_table_name(name)?; - let path = Path::new(&self.uri); - let table_uri = path.join(format!("{}.{}", name, LANCE_FILE_EXTENSION)); - - let mut uri = table_uri - .as_path() - .to_str() - .context(InvalidTableNameSnafu { - name, - reason: "Name is not valid URL", - })? - .to_string(); + let mut uri = self.uri.clone(); + // If the URI does not end with a slash, add one + if !uri.ends_with('/') { + uri.push('/'); + } + // Append the table name with the lance file extension + uri.push_str(&format!("{}.{}", name, LANCE_FILE_EXTENSION)); // If there are query string set on the connection, propagate to lance if let Some(query) = self.query_string.as_ref() {