From 4fb76e762e9daf253ff48e515911513a6264ceb8 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 5 Jul 2024 22:42:40 +0800 Subject: [PATCH 1/3] fix: Fix build while no-default-features enabled Signed-off-by: Xuanwo --- crates/iceberg/src/io/mod.rs | 4 ++++ crates/iceberg/src/io/storage.rs | 20 ++++++++++++++++---- crates/iceberg/src/runtime/mod.rs | 10 ++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/iceberg/src/io/mod.rs b/crates/iceberg/src/io/mod.rs index 6da605d74..914293da3 100644 --- a/crates/iceberg/src/io/mod.rs +++ b/crates/iceberg/src/io/mod.rs @@ -52,7 +52,11 @@ mod file_io; pub use file_io::*; mod storage; +#[cfg(feature = "storage-s3")] mod storage_s3; +#[cfg(feature = "storage-s3")] pub use storage_s3::*; +#[cfg(feature = "storage-fs")] mod storage_fs; +#[cfg(feature = "storage-fs")] use storage_fs::*; diff --git a/crates/iceberg/src/io/storage.rs b/crates/iceberg/src/io/storage.rs index b188c2908..262fbcea5 100644 --- a/crates/iceberg/src/io/storage.rs +++ b/crates/iceberg/src/io/storage.rs @@ -15,16 +15,20 @@ // specific language governing permissions and limitations // under the License. -use super::{FileIOBuilder, FsConfig, S3Config}; +use super::FileIOBuilder; +#[cfg(feature = "storage-fs")] +use super::FsConfig; +#[cfg(feature = "storage-s3")] +use super::S3Config; use crate::{Error, ErrorKind}; use opendal::{Operator, Scheme}; /// The storage carries all supported storage services in iceberg #[derive(Debug)] pub(crate) enum Storage { - LocalFs { - config: FsConfig, - }, + #[cfg(feature = "storage-fs")] + LocalFs { config: FsConfig }, + #[cfg(feature = "storage-s3")] S3 { /// s3 storage could have `s3://` and `s3a://`. /// Storing the scheme string here to return the correct path. @@ -40,9 +44,11 @@ impl Storage { let scheme = Self::parse_scheme(&scheme_str)?; match scheme { + #[cfg(feature = "storage-fs")] Scheme::Fs => Ok(Self::LocalFs { config: FsConfig::new(props), }), + #[cfg(feature = "storage-s3")] Scheme::S3 => Ok(Self::S3 { scheme_str, config: S3Config::new(props), @@ -73,6 +79,7 @@ impl Storage { ) -> crate::Result<(Operator, &'a str)> { let path = path.as_ref(); match self { + #[cfg(feature = "storage-fs")] Storage::LocalFs { config } => { let op = config.build(path)?; @@ -82,6 +89,7 @@ impl Storage { Ok((op, &path[1..])) } } + #[cfg(feature = "storage-s3")] Storage::S3 { scheme_str, config } => { let op = config.build(path)?; let op_info = op.info(); @@ -97,6 +105,10 @@ impl Storage { )) } } + _ => Err(Error::new( + ErrorKind::FeatureUnsupported, + "No storage service has been enabled", + )), } } diff --git a/crates/iceberg/src/runtime/mod.rs b/crates/iceberg/src/runtime/mod.rs index 453b1564a..65c30e82c 100644 --- a/crates/iceberg/src/runtime/mod.rs +++ b/crates/iceberg/src/runtime/mod.rs @@ -26,6 +26,8 @@ pub enum JoinHandle { Tokio(tokio::task::JoinHandle), #[cfg(all(feature = "async-std", not(feature = "tokio")))] AsyncStd(async_std::task::JoinHandle), + #[cfg(all(not(feature = "async-std"), not(feature = "tokio")))] + Unimplemented(Box), } impl Future for JoinHandle { @@ -39,6 +41,8 @@ impl Future for JoinHandle { .map(|h| h.expect("tokio spawned task failed")), #[cfg(all(feature = "async-std", not(feature = "tokio")))] JoinHandle::AsyncStd(handle) => Pin::new(handle).poll(cx), + #[cfg(all(not(feature = "async-std"), not(feature = "tokio")))] + JoinHandle::Unimplemented(_) => unimplemented!("no runtime has been enabled"), } } } @@ -54,6 +58,9 @@ where #[cfg(all(feature = "async-std", not(feature = "tokio")))] return JoinHandle::AsyncStd(async_std::task::spawn(f)); + + #[cfg(all(not(feature = "async-std"), not(feature = "tokio")))] + unimplemented!("no runtime has been enabled") } #[allow(dead_code)] @@ -67,6 +74,9 @@ where #[cfg(all(feature = "async-std", not(feature = "tokio")))] return JoinHandle::AsyncStd(async_std::task::spawn_blocking(f)); + + #[cfg(all(not(feature = "async-std"), not(feature = "tokio")))] + unimplemented!("no runtime has been enabled") } #[cfg(test)] From 3f643a86416bc030a3b0637b2422fbfe7ca245c0 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 5 Jul 2024 22:43:49 +0800 Subject: [PATCH 2/3] Fix clippy Signed-off-by: Xuanwo --- crates/iceberg/src/io/storage.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/iceberg/src/io/storage.rs b/crates/iceberg/src/io/storage.rs index 262fbcea5..8d7df45b8 100644 --- a/crates/iceberg/src/io/storage.rs +++ b/crates/iceberg/src/io/storage.rs @@ -105,6 +105,7 @@ impl Storage { )) } } + #[cfg(all(not(feature = "storage-s3"), not(feature = "storage-fs")))] _ => Err(Error::new( ErrorKind::FeatureUnsupported, "No storage service has been enabled", From ad8602f9c0469f58c6f81acdaf73a49d321e45ad Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 5 Jul 2024 22:45:43 +0800 Subject: [PATCH 3/3] Add ci for no default features Signed-off-by: Xuanwo --- .github/workflows/ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5be609c0b..536089fce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: - name: Cargo sort run: make cargo-sort - build: runs-on: ${{ matrix.os }} strategy: @@ -64,6 +63,19 @@ jobs: - name: Build run: cargo build + build_with_no_default_features: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build -p iceberg --no-default-features + unit: runs-on: ubuntu-latest steps: