This is an automated email from the ASF dual-hosted git repository.
liurenjie1024 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new cafc939d fix: OpenDAL `is_exist` => `exists` (#680)
cafc939d is described below
commit cafc939d6aa303f7424a74fa8467ac0cb306591d
Author: Scott Donnelly <[email protected]>
AuthorDate: Fri Oct 25 02:36:05 2024 +0100
fix: OpenDAL `is_exist` => `exists` (#680)
* change usage of deprecated OpenDAL `is_exist` method to its replacement,
`exists`
* perform similar change to `FileIO::exists`
Fixes: https://github.com/apache/iceberg-rust/issues/679
---
Cargo.toml | 2 +-
crates/catalog/glue/tests/glue_catalog_test.rs | 2 +-
crates/catalog/hms/tests/hms_catalog_test.rs | 2 +-
crates/iceberg/src/io/file_io.rs | 30 +++++++++++---------------
crates/iceberg/src/io/mod.rs | 2 +-
crates/iceberg/tests/file_io_gcs_test.rs | 9 +++-----
crates/iceberg/tests/file_io_s3_test.rs | 10 ++++-----
7 files changed, 24 insertions(+), 33 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 5e2b8973..bce6470d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -71,7 +71,7 @@ log = "0.4"
mockito = "1"
murmur3 = "0.5.2"
once_cell = "1"
-opendal = "0.50"
+opendal = "0.50.1"
ordered-float = "4"
parquet = "53"
paste = "1"
diff --git a/crates/catalog/glue/tests/glue_catalog_test.rs
b/crates/catalog/glue/tests/glue_catalog_test.rs
index d9c5b4e0..ebfb1f43 100644
--- a/crates/catalog/glue/tests/glue_catalog_test.rs
+++ b/crates/catalog/glue/tests/glue_catalog_test.rs
@@ -237,7 +237,7 @@ async fn test_create_table() -> Result<()> {
assert!(
catalog
.file_io()
- .is_exist("s3a://warehouse/hive/metadata/")
+ .exists("s3a://warehouse/hive/metadata/")
.await?
);
diff --git a/crates/catalog/hms/tests/hms_catalog_test.rs
b/crates/catalog/hms/tests/hms_catalog_test.rs
index 5b800443..37a95941 100644
--- a/crates/catalog/hms/tests/hms_catalog_test.rs
+++ b/crates/catalog/hms/tests/hms_catalog_test.rs
@@ -212,7 +212,7 @@ async fn test_create_table() -> Result<()> {
assert!(
catalog
.file_io()
- .is_exist("s3a://warehouse/hive/metadata/")
+ .exists("s3a://warehouse/hive/metadata/")
.await?
);
diff --git a/crates/iceberg/src/io/file_io.rs b/crates/iceberg/src/io/file_io.rs
index 1ac2c1cd..8365d622 100644
--- a/crates/iceberg/src/io/file_io.rs
+++ b/crates/iceberg/src/io/file_io.rs
@@ -95,9 +95,9 @@ impl FileIO {
/// # Arguments
///
/// * path: It should be *absolute* path starting with scheme string used
to construct [`FileIO`].
- pub async fn is_exist(&self, path: impl AsRef<str>) -> Result<bool> {
+ pub async fn exists(&self, path: impl AsRef<str>) -> Result<bool> {
let (op, relative_path) = self.inner.create_operator(&path)?;
- Ok(op.is_exist(relative_path).await?)
+ Ok(op.exists(relative_path).await?)
}
/// Creates input file.
@@ -241,10 +241,7 @@ impl InputFile {
/// Check if file exists.
pub async fn exists(&self) -> crate::Result<bool> {
- Ok(self
- .op
- .is_exist(&self.path[self.relative_path_pos..])
- .await?)
+ Ok(self.op.exists(&self.path[self.relative_path_pos..]).await?)
}
/// Fetch and returns metadata of file.
@@ -323,10 +320,7 @@ impl OutputFile {
/// Checks if file exists.
pub async fn exists(&self) -> crate::Result<bool> {
- Ok(self
- .op
- .is_exist(&self.path[self.relative_path_pos..])
- .await?)
+ Ok(self.op.exists(&self.path[self.relative_path_pos..]).await?)
}
/// Converts into [`InputFile`].
@@ -426,15 +420,15 @@ mod tests {
write_to_file("Iceberg loves rust.", &c_path);
let file_io = create_local_file_io();
- assert!(file_io.is_exist(&a_path).await.unwrap());
+ assert!(file_io.exists(&a_path).await.unwrap());
file_io.remove_all(&sub_dir_path).await.unwrap();
- assert!(!file_io.is_exist(&b_path).await.unwrap());
- assert!(!file_io.is_exist(&c_path).await.unwrap());
- assert!(file_io.is_exist(&a_path).await.unwrap());
+ assert!(!file_io.exists(&b_path).await.unwrap());
+ assert!(!file_io.exists(&c_path).await.unwrap());
+ assert!(file_io.exists(&a_path).await.unwrap());
file_io.delete(&a_path).await.unwrap();
- assert!(!file_io.is_exist(&a_path).await.unwrap());
+ assert!(!file_io.exists(&a_path).await.unwrap());
}
#[tokio::test]
@@ -445,7 +439,7 @@ mod tests {
let full_path = format!("{}/{}", tmp_dir.path().to_str().unwrap(),
file_name);
let file_io = create_local_file_io();
- assert!(!file_io.is_exist(&full_path).await.unwrap());
+ assert!(!file_io.exists(&full_path).await.unwrap());
assert!(file_io.delete(&full_path).await.is_ok());
assert!(file_io.remove_all(&full_path).await.is_ok());
}
@@ -501,12 +495,12 @@ mod tests {
let output_file = io.new_output(&path).unwrap();
output_file.write("test".into()).await.unwrap();
- assert!(io.is_exist(&path.clone()).await.unwrap());
+ assert!(io.exists(&path.clone()).await.unwrap());
let input_file = io.new_input(&path).unwrap();
let content = input_file.read().await.unwrap();
assert_eq!(content, Bytes::from("test"));
io.delete(&path).await.unwrap();
- assert!(!io.is_exist(&path).await.unwrap());
+ assert!(!io.exists(&path).await.unwrap());
}
}
diff --git a/crates/iceberg/src/io/mod.rs b/crates/iceberg/src/io/mod.rs
index 52a1da23..aaac734d 100644
--- a/crates/iceberg/src/io/mod.rs
+++ b/crates/iceberg/src/io/mod.rs
@@ -62,7 +62,7 @@
//! Currently `FileIO` provides simple methods for file operations:
//!
//! - `delete`: Delete file.
-//! - `is_exist`: Check if file exists.
+//! - `exists`: Check if file exists.
//! - `new_input`: Create input file for reading.
//! - `new_output`: Create output file for writing.
diff --git a/crates/iceberg/tests/file_io_gcs_test.rs
b/crates/iceberg/tests/file_io_gcs_test.rs
index 540cd9d9..f7846557 100644
--- a/crates/iceberg/tests/file_io_gcs_test.rs
+++ b/crates/iceberg/tests/file_io_gcs_test.rs
@@ -93,10 +93,7 @@ mod tests {
#[tokio::test]
async fn gcs_exists() {
let file_io = get_file_io_gcs().await;
- assert!(file_io
- .is_exist(format!("{}/", get_gs_path()))
- .await
- .unwrap());
+ assert!(file_io.exists(format!("{}/", get_gs_path())).await.unwrap());
}
#[tokio::test]
@@ -108,7 +105,7 @@ mod tests {
.write(bytes::Bytes::from_static(b"iceberg-gcs!"))
.await
.expect("Write to test output file");
- assert!(file_io.is_exist(gs_file).await.unwrap())
+ assert!(file_io.exists(gs_file).await.unwrap())
}
#[tokio::test]
@@ -120,7 +117,7 @@ mod tests {
.write(bytes::Bytes::from_static(b"iceberg!"))
.await
.expect("Write to test output file");
- assert!(file_io.is_exist(&gs_file).await.unwrap());
+ assert!(file_io.exists(&gs_file).await.unwrap());
let input = file_io.new_input(gs_file).unwrap();
assert_eq!(input.read().await.unwrap(),
Bytes::from_static(b"iceberg!"));
diff --git a/crates/iceberg/tests/file_io_s3_test.rs
b/crates/iceberg/tests/file_io_s3_test.rs
index 32e2d12a..22b798fc 100644
--- a/crates/iceberg/tests/file_io_s3_test.rs
+++ b/crates/iceberg/tests/file_io_s3_test.rs
@@ -68,21 +68,21 @@ mod tests {
}
#[tokio::test]
- async fn test_file_io_s3_is_exist() {
+ async fn test_file_io_s3_exists() {
let file_io = get_file_io().await;
- assert!(!file_io.is_exist("s3://bucket2/any").await.unwrap());
- assert!(file_io.is_exist("s3://bucket1/").await.unwrap());
+ assert!(!file_io.exists("s3://bucket2/any").await.unwrap());
+ assert!(file_io.exists("s3://bucket1/").await.unwrap());
}
#[tokio::test]
async fn test_file_io_s3_output() {
let file_io = get_file_io().await;
- assert!(!file_io.is_exist("s3://bucket1/test_output").await.unwrap());
+ assert!(!file_io.exists("s3://bucket1/test_output").await.unwrap());
let output_file =
file_io.new_output("s3://bucket1/test_output").unwrap();
{
output_file.write("123".into()).await.unwrap();
}
- assert!(file_io.is_exist("s3://bucket1/test_output").await.unwrap());
+ assert!(file_io.exists("s3://bucket1/test_output").await.unwrap());
}
#[tokio::test]