Skip to content

Commit

Permalink
fix test case and python
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinLin666 committed Mar 11, 2024
1 parent 7b1748d commit 27c88c9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions crates/mount/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ impl ObjectStoreFactory for MountFactory {
.get(&config::MountConfigKey::AllowUnsafeRename)
.unwrap_or(&String::new()),
);
println!("allow_unsafe_rename: {}", allow_unsafe_rename);
println!("url: {}", url);

match url.scheme() {
"dbfs" => {
if !allow_unsafe_rename {
// Just let the user know that they need to set the allow_unsafe_rename option
return Err(error::Error::AllowUnsafeRenameNotSpecified.into());
}
// We need to convert the dbfs url to a file url
let new_url = Url::parse(&format!("file:///dbfs{}", url.path())).unwrap();
let store = Arc::new(file::MountFileStorageBackend::try_new(
new_url.to_file_path().unwrap(),
Expand Down
10 changes: 8 additions & 2 deletions crates/mount/tests/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Default for DbfsIntegration {
fn default() -> Self {
register_handlers(None);
Self {
tmp_dir: TempDir::with_prefix("/dbfs/").expect("Failed to make temp dir"),
tmp_dir: tempdir().expect("Failed to make temp dir"),
}
}
}
Expand All @@ -61,6 +61,8 @@ impl StorageIntegration for DbfsIntegration {

fn prepare_env(&self) {
set_env_if_not_set("MOUNT_ALLOW_UNSAFE_RENAME", "true");
std::fs::create_dir_all(format!("/dbfs{}", self.tmp_dir.as_ref().to_str().unwrap()))
.expect("Failed to create dir");
}
fn bucket_name(&self) -> String {
self.tmp_dir.as_ref().to_str().unwrap().to_owned()
Expand All @@ -71,7 +73,11 @@ impl StorageIntegration for DbfsIntegration {
fn copy_directory(&self, source: &str, destination: &str) -> std::io::Result<ExitStatus> {
let mut options = CopyOptions::new();
options.content_only = true;
let dest_path = self.tmp_dir.path().join(destination);
let dest_path = format!(
"/dbfs{}/{}",
self.tmp_dir.as_ref().to_str().unwrap(),
destination
);
std::fs::create_dir_all(&dest_path)?;
copy(source, &dest_path, &options).expect("Failed to copy");
Ok(ExitStatus::default())
Expand Down
2 changes: 1 addition & 1 deletion crates/mount/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #![cfg(feature = "integration_test")]
#![cfg(feature = "integration_test")]

use deltalake_test::read::read_table_paths;
use deltalake_test::{test_read_tables, IntegrationContext, TestResult};
Expand Down
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ features = ["extension-module", "abi3", "abi3-py38"]
[dependencies.deltalake]
path = "../crates/deltalake"
version = "0"
features = ["azure", "gcs", "python", "datafusion", "unity-experimental"]
features = ["azure", "gcs", "python", "datafusion", "unity-experimental", "mount"]

[features]
default = ["rustls"]
Expand Down
1 change: 1 addition & 0 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,7 @@ fn _internal(py: Python, m: &PyModule) -> PyResult<()> {
deltalake::aws::register_handlers(None);
deltalake::azure::register_handlers(None);
deltalake::gcp::register_handlers(None);
deltalake::mount::register_handlers(None);

m.add("DeltaError", py.get_type::<DeltaError>())?;
m.add("CommitFailedError", py.get_type::<CommitFailedError>())?;
Expand Down

0 comments on commit 27c88c9

Please sign in to comment.