Skip to content

Commit cf6998e

Browse files
committed
Pass scheme strings cleanly
1 parent 96fe4a0 commit cf6998e

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

crates/iceberg/src/io/file_io.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use url::Url;
2727

2828
// Re-export traits from storage module
2929
pub use super::storage::{Storage, StorageBuilder};
30-
use crate::io::StorageBuilderRegistry;
30+
use crate::io::{StorageBuilderRegistry, STORAGE_LOCATION_SCHEME};
3131
use crate::{Error, ErrorKind, Result};
3232

3333
/// FileIO implementation, used to manipulate files in underlying storage.
@@ -321,8 +321,11 @@ impl FileIOBuilder {
321321

322322
let builder = registry.get_builder(scheme.as_str())?;
323323

324+
let mut props_with_scheme = self.props.clone();
325+
props_with_scheme.insert(STORAGE_LOCATION_SCHEME.to_string(), scheme);
326+
324327
// Build storage with props and extensions
325-
let storage = builder.build(self.props.clone(), self.extensions.clone())?;
328+
let storage = builder.build(props_with_scheme, self.extensions.clone())?;
326329

327330
Ok(FileIO {
328331
builder: self,

crates/iceberg/src/io/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ pub use file_io::*;
7373
pub use storage::{Storage, StorageBuilder, StorageBuilderRegistry};
7474
pub(crate) mod object_cache;
7575

76+
/// Property key used to pass the scheme string to storage builders.
77+
///
78+
/// Custom storage implementations can use this constant to retrieve the scheme
79+
/// from the properties map passed to `StorageBuilder::build()`.
80+
pub const STORAGE_LOCATION_SCHEME: &str = "iceberg.storage.location.scheme";
81+
7682
#[cfg(feature = "storage-azdls")]
7783
mod storage_azdls;
7884
#[cfg(feature = "storage-fs")]

crates/iceberg/src/io/storage_azdls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use url::Url;
2828

2929
use crate::io::{
3030
Extensions, FileMetadata, FileRead, FileWrite, InputFile, OutputFile, Storage, StorageBuilder,
31+
STORAGE_LOCATION_SCHEME,
3132
};
3233
use crate::{Error, ErrorKind, Result, ensure_data_valid};
3334

@@ -695,7 +696,7 @@ impl StorageBuilder for OpenDALAzdlsStorageBuilder {
695696
) -> Result<Arc<dyn Storage>> {
696697
// Get the scheme string from the props or use default
697698
let scheme_str = props
698-
.get("scheme_str")
699+
.get(STORAGE_LOCATION_SCHEME)
699700
.cloned()
700701
.unwrap_or_else(|| "abfs".to_string());
701702

crates/iceberg/src/io/storage_s3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use url::Url;
2828

2929
use crate::io::{
3030
Extensions, FileMetadata, FileRead, FileWrite, InputFile, OutputFile, Storage, StorageBuilder,
31-
is_truthy,
31+
is_truthy, STORAGE_LOCATION_SCHEME,
3232
};
3333
use crate::{Error, ErrorKind, Result};
3434

@@ -334,7 +334,7 @@ impl StorageBuilder for OpenDALS3StorageBuilder {
334334
) -> Result<Arc<dyn Storage>> {
335335
// Get the scheme string from the props or use "s3" as default
336336
let scheme_str = props
337-
.get("scheme_str")
337+
.get(STORAGE_LOCATION_SCHEME)
338338
.cloned()
339339
.unwrap_or_else(|| "s3".to_string());
340340

0 commit comments

Comments
 (0)