Skip to content

Commit 42c53b7

Browse files
committed
use resolving storage for python binding
1 parent ffd6454 commit 42c53b7

1 file changed

Lines changed: 3 additions & 26 deletions

File tree

bindings/python/src/datafusion_table_provider.rs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,16 @@ use std::sync::Arc;
2222
use datafusion_ffi::proto::logical_extension_codec::FFI_LogicalExtensionCodec;
2323
use datafusion_ffi::table_provider::FFI_TableProvider;
2424
use iceberg::TableIdent;
25-
use iceberg::io::{FileIOBuilder, StorageFactory};
25+
use iceberg::io::FileIOBuilder;
2626
use iceberg::table::StaticTable;
2727
use iceberg_datafusion::table::IcebergStaticTableProvider;
28-
use iceberg_storage_opendal::OpenDalStorageFactory;
28+
use iceberg_storage_opendal::OpenDalResolvingStorageFactory;
2929
use pyo3::exceptions::{PyRuntimeError, PyValueError};
3030
use pyo3::prelude::{PyAnyMethods, PyCapsuleMethods, *};
3131
use pyo3::types::{PyAny, PyCapsule};
3232

3333
use crate::runtime::runtime;
3434

35-
/// Parse the scheme from a URL and return the appropriate StorageFactory.
36-
fn storage_factory_from_path(path: &str) -> PyResult<Arc<dyn StorageFactory>> {
37-
let scheme = path
38-
.split("://")
39-
.next()
40-
.ok_or_else(|| PyRuntimeError::new_err(format!("Invalid path, missing scheme: {path}")))?;
41-
42-
let factory: Arc<dyn StorageFactory> = match scheme {
43-
"file" | "" => Arc::new(OpenDalStorageFactory::Fs),
44-
"s3" | "s3a" => Arc::new(OpenDalStorageFactory::S3 {
45-
configured_scheme: scheme.to_string(),
46-
customized_credential_load: None,
47-
}),
48-
"memory" => Arc::new(OpenDalStorageFactory::Memory),
49-
_ => {
50-
return Err(PyRuntimeError::new_err(format!(
51-
"Unsupported storage scheme: {scheme}"
52-
)));
53-
}
54-
};
55-
56-
Ok(factory)
57-
}
5835

5936
pub(crate) fn validate_pycapsule(capsule: &Bound<PyCapsule>, name: &str) -> PyResult<()> {
6037
let capsule_name = capsule.name()?;
@@ -110,7 +87,7 @@ impl PyIcebergDataFusionTable {
11087
let table_ident = TableIdent::from_strs(identifier)
11188
.map_err(|e| PyRuntimeError::new_err(format!("Invalid table identifier: {e}")))?;
11289

113-
let factory = storage_factory_from_path(&metadata_location)?;
90+
let factory = Arc::new(OpenDalResolvingStorageFactory::new());
11491

11592
let mut builder = FileIOBuilder::new(factory);
11693

0 commit comments

Comments
 (0)