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 5bfb8bd fix: Fix build while no-default-features enabled (#442)
5bfb8bd is described below
commit 5bfb8bdd4ec124e005e86af7331e8da08c1445ed
Author: Xuanwo <[email protected]>
AuthorDate: Sat Jul 6 18:12:25 2024 +0800
fix: Fix build while no-default-features enabled (#442)
* fix: Fix build while no-default-features enabled
Signed-off-by: Xuanwo <[email protected]>
* Fix clippy
Signed-off-by: Xuanwo <[email protected]>
* Add ci for no default features
Signed-off-by: Xuanwo <[email protected]>
---------
Signed-off-by: Xuanwo <[email protected]>
---
.github/workflows/ci.yml | 14 +++++++++++++-
crates/iceberg/src/io/mod.rs | 4 ++++
crates/iceberg/src/io/storage.rs | 21 +++++++++++++++++----
crates/iceberg/src/runtime/mod.rs | 10 ++++++++++
4 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5be609c..536089f 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:
diff --git a/crates/iceberg/src/io/mod.rs b/crates/iceberg/src/io/mod.rs
index 6da605d..914293d 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 b188c29..8d7df45 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,11 @@ impl Storage {
))
}
}
+ #[cfg(all(not(feature = "storage-s3"), not(feature =
"storage-fs")))]
+ _ => 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 453b156..65c30e8 100644
--- a/crates/iceberg/src/runtime/mod.rs
+++ b/crates/iceberg/src/runtime/mod.rs
@@ -26,6 +26,8 @@ pub enum JoinHandle<T> {
Tokio(tokio::task::JoinHandle<T>),
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
AsyncStd(async_std::task::JoinHandle<T>),
+ #[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
+ Unimplemented(Box<T>),
}
impl<T: Send + 'static> Future for JoinHandle<T> {
@@ -39,6 +41,8 @@ impl<T: Send + 'static> Future for JoinHandle<T> {
.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)]