Skip to content

Commit c128ee9

Browse files
committed
dal clean yet?
1 parent b3e0ab4 commit c128ee9

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

crates/iceberg/src/io/file_io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::sync::Arc;
2424
use bytes::Bytes;
2525
use url::Url;
2626

27-
use super::storage::OpenDALStorage;
27+
use super::storage::OpenDalStorage;
2828
pub use super::storage::Storage;
2929
use crate::{Error, ErrorKind, Result};
3030

@@ -240,7 +240,7 @@ impl FileIOBuilder {
240240

241241
/// Builds [`FileIO`].
242242
pub fn build(self) -> Result<FileIO> {
243-
let storage = OpenDALStorage::build(self.clone())?;
243+
let storage = OpenDalStorage::build(self.clone())?;
244244

245245
Ok(FileIO {
246246
builder: self,

crates/iceberg/src/io/storage.rs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,19 @@ pub trait Storage: Debug + Send + Sync {
8888
/// This storage handles all supported schemes (S3, GCS, Azure, filesystem, memory)
8989
/// through OpenDAL, creating operators on-demand based on the path scheme.
9090
#[derive(Debug, Clone, Serialize, Deserialize)]
91-
pub(crate) enum OpenDALStorage {
91+
pub(crate) enum OpenDalStorage {
9292
/// In-memory storage, useful for testing
9393
#[cfg(feature = "storage-memory")]
9494
Memory(#[serde(skip, default = "default_memory_op")] Operator),
9595
/// Local filesystem storage
9696
#[cfg(feature = "storage-fs")]
9797
LocalFs,
9898
/// Amazon S3 storage
99+
/// Expects paths of the form `s3[a]://<bucket>/<path>`.
99100
#[cfg(feature = "storage-s3")]
100101
S3 {
101-
/// The configured scheme (s3 or s3a)
102+
/// s3 storage could have `s3://` and `s3a://`.
103+
/// Storing the scheme string here to return the correct path.
102104
configured_scheme: String,
103105
/// S3 configuration
104106
config: Arc<S3Config>,
@@ -119,6 +121,9 @@ pub(crate) enum OpenDALStorage {
119121
config: Arc<OssConfig>,
120122
},
121123
/// Azure Data Lake Storage
124+
/// Expects paths of the form
125+
/// `abfs[s]://<filesystem>@<account>.dfs.<endpoint-suffix>/<path>` or
126+
/// `wasb[s]://<container>@<account>.blob.<endpoint-suffix>/<path>`.
122127
#[cfg(feature = "storage-azdls")]
123128
Azdls {
124129
/// Because Azdls accepts multiple possible schemes, we store the full
@@ -134,7 +139,7 @@ fn default_memory_op() -> Operator {
134139
super::memory_config_build().expect("Failed to build memory operator")
135140
}
136141

137-
impl OpenDALStorage {
142+
impl OpenDalStorage {
138143
/// Build storage from FileIOBuilder
139144
pub fn build(file_io_builder: FileIOBuilder) -> Result<Self> {
140145
let (scheme_str, props, extensions) = file_io_builder.into_parts();
@@ -149,29 +154,23 @@ impl OpenDALStorage {
149154
Scheme::Fs => Ok(Self::LocalFs),
150155

151156
#[cfg(feature = "storage-s3")]
152-
Scheme::S3 => {
153-
Ok(Self::S3 {
154-
configured_scheme: scheme_str,
155-
config: super::s3_config_parse(props)?.into(),
156-
customized_credential_load: extensions
157+
Scheme::S3 => Ok(Self::S3 {
158+
configured_scheme: scheme_str,
159+
config: super::s3_config_parse(props)?.into(),
160+
customized_credential_load: extensions
157161
.get::<super::CustomAwsCredentialLoader>()
158162
.map(Arc::unwrap_or_clone),
159-
})
160-
}
163+
}),
161164

162165
#[cfg(feature = "storage-gcs")]
163-
Scheme::Gcs => {
164-
Ok(Self::Gcs {
165-
config: super::gcs_config_parse(props)?.into(),
166-
})
167-
}
166+
Scheme::Gcs => Ok(Self::Gcs {
167+
config: super::gcs_config_parse(props)?.into(),
168+
}),
168169

169170
#[cfg(feature = "storage-oss")]
170-
Scheme::Oss => {
171-
Ok(Self::Oss {
172-
config: super::oss_config_parse(props)?.into(),
173-
})
174-
}
171+
Scheme::Oss => Ok(Self::Oss {
172+
config: super::oss_config_parse(props)?.into(),
173+
}),
175174

176175
#[cfg(feature = "storage-azdls")]
177176
Scheme::Azdls => {
@@ -314,7 +313,7 @@ impl OpenDALStorage {
314313

315314
#[async_trait]
316315
#[typetag::serde]
317-
impl Storage for OpenDALStorage {
316+
impl Storage for OpenDalStorage {
318317
async fn exists(&self, path: &str) -> Result<bool> {
319318
let (op, relative_path) = self.create_operator(path)?;
320319
Ok(op.exists(relative_path).await?)
@@ -382,38 +381,38 @@ mod tests {
382381
#[cfg(feature = "storage-memory")]
383382
fn test_opendal_storage_memory() {
384383
let builder = FileIOBuilder::new("memory");
385-
let storage = OpenDALStorage::build(builder).unwrap();
386-
assert!(matches!(storage, OpenDALStorage::Memory { .. }));
384+
let storage = OpenDalStorage::build(builder).unwrap();
385+
assert!(matches!(storage, OpenDalStorage::Memory { .. }));
387386
}
388387

389388
#[test]
390389
#[cfg(feature = "storage-fs")]
391390
fn test_opendal_storage_fs() {
392391
let builder = FileIOBuilder::new("file");
393-
let storage = OpenDALStorage::build(builder).unwrap();
394-
assert!(matches!(storage, OpenDALStorage::LocalFs));
392+
let storage = OpenDalStorage::build(builder).unwrap();
393+
assert!(matches!(storage, OpenDalStorage::LocalFs));
395394
}
396395

397396
#[test]
398397
#[cfg(feature = "storage-s3")]
399398
fn test_opendal_storage_s3() {
400399
let builder = FileIOBuilder::new("s3");
401-
let storage = OpenDALStorage::build(builder).unwrap();
402-
assert!(matches!(storage, OpenDALStorage::S3 { .. }));
400+
let storage = OpenDalStorage::build(builder).unwrap();
401+
assert!(matches!(storage, OpenDalStorage::S3 { .. }));
403402
}
404403

405404
#[test]
406405
#[cfg(feature = "storage-memory")]
407406
fn test_storage_serialization() {
408407
let builder = FileIOBuilder::new("memory");
409-
let storage = OpenDALStorage::build(builder).unwrap();
408+
let storage = OpenDalStorage::build(builder).unwrap();
410409

411410
// Serialize
412411
let serialized = serde_json::to_string(&storage).unwrap();
413412

414413
// Deserialize
415-
let deserialized: OpenDALStorage = serde_json::from_str(&serialized).unwrap();
414+
let deserialized: OpenDalStorage = serde_json::from_str(&serialized).unwrap();
416415

417-
assert!(matches!(deserialized, OpenDALStorage::Memory { .. }));
416+
assert!(matches!(deserialized, OpenDalStorage::Memory { .. }));
418417
}
419418
}

0 commit comments

Comments
 (0)