Skip to content

Commit 5bfb8bd

Browse files
authored
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]>
1 parent dba6059 commit 5bfb8bd

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
- name: Cargo sort
5151
run: make cargo-sort
5252

53-
5453
build:
5554
runs-on: ${{ matrix.os }}
5655
strategy:
@@ -64,6 +63,19 @@ jobs:
6463
- name: Build
6564
run: cargo build
6665

66+
build_with_no_default_features:
67+
runs-on: ${{ matrix.os }}
68+
strategy:
69+
matrix:
70+
os:
71+
- ubuntu-latest
72+
- macos-latest
73+
- windows-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
- name: Build
77+
run: cargo build -p iceberg --no-default-features
78+
6779
unit:
6880
runs-on: ubuntu-latest
6981
steps:

crates/iceberg/src/io/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ mod file_io;
5252
pub use file_io::*;
5353

5454
mod storage;
55+
#[cfg(feature = "storage-s3")]
5556
mod storage_s3;
57+
#[cfg(feature = "storage-s3")]
5658
pub use storage_s3::*;
59+
#[cfg(feature = "storage-fs")]
5760
mod storage_fs;
61+
#[cfg(feature = "storage-fs")]
5862
use storage_fs::*;

crates/iceberg/src/io/storage.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use super::{FileIOBuilder, FsConfig, S3Config};
18+
use super::FileIOBuilder;
19+
#[cfg(feature = "storage-fs")]
20+
use super::FsConfig;
21+
#[cfg(feature = "storage-s3")]
22+
use super::S3Config;
1923
use crate::{Error, ErrorKind};
2024
use opendal::{Operator, Scheme};
2125

2226
/// The storage carries all supported storage services in iceberg
2327
#[derive(Debug)]
2428
pub(crate) enum Storage {
25-
LocalFs {
26-
config: FsConfig,
27-
},
29+
#[cfg(feature = "storage-fs")]
30+
LocalFs { config: FsConfig },
31+
#[cfg(feature = "storage-s3")]
2832
S3 {
2933
/// s3 storage could have `s3://` and `s3a://`.
3034
/// Storing the scheme string here to return the correct path.
@@ -40,9 +44,11 @@ impl Storage {
4044
let scheme = Self::parse_scheme(&scheme_str)?;
4145

4246
match scheme {
47+
#[cfg(feature = "storage-fs")]
4348
Scheme::Fs => Ok(Self::LocalFs {
4449
config: FsConfig::new(props),
4550
}),
51+
#[cfg(feature = "storage-s3")]
4652
Scheme::S3 => Ok(Self::S3 {
4753
scheme_str,
4854
config: S3Config::new(props),
@@ -73,6 +79,7 @@ impl Storage {
7379
) -> crate::Result<(Operator, &'a str)> {
7480
let path = path.as_ref();
7581
match self {
82+
#[cfg(feature = "storage-fs")]
7683
Storage::LocalFs { config } => {
7784
let op = config.build(path)?;
7885

@@ -82,6 +89,7 @@ impl Storage {
8289
Ok((op, &path[1..]))
8390
}
8491
}
92+
#[cfg(feature = "storage-s3")]
8593
Storage::S3 { scheme_str, config } => {
8694
let op = config.build(path)?;
8795
let op_info = op.info();
@@ -97,6 +105,11 @@ impl Storage {
97105
))
98106
}
99107
}
108+
#[cfg(all(not(feature = "storage-s3"), not(feature = "storage-fs")))]
109+
_ => Err(Error::new(
110+
ErrorKind::FeatureUnsupported,
111+
"No storage service has been enabled",
112+
)),
100113
}
101114
}
102115

crates/iceberg/src/runtime/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub enum JoinHandle<T> {
2626
Tokio(tokio::task::JoinHandle<T>),
2727
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
2828
AsyncStd(async_std::task::JoinHandle<T>),
29+
#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
30+
Unimplemented(Box<T>),
2931
}
3032

3133
impl<T: Send + 'static> Future for JoinHandle<T> {
@@ -39,6 +41,8 @@ impl<T: Send + 'static> Future for JoinHandle<T> {
3941
.map(|h| h.expect("tokio spawned task failed")),
4042
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
4143
JoinHandle::AsyncStd(handle) => Pin::new(handle).poll(cx),
44+
#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
45+
JoinHandle::Unimplemented(_) => unimplemented!("no runtime has been enabled"),
4246
}
4347
}
4448
}
@@ -54,6 +58,9 @@ where
5458

5559
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
5660
return JoinHandle::AsyncStd(async_std::task::spawn(f));
61+
62+
#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
63+
unimplemented!("no runtime has been enabled")
5764
}
5865

5966
#[allow(dead_code)]
@@ -67,6 +74,9 @@ where
6774

6875
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
6976
return JoinHandle::AsyncStd(async_std::task::spawn_blocking(f));
77+
78+
#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
79+
unimplemented!("no runtime has been enabled")
7080
}
7181

7282
#[cfg(test)]

0 commit comments

Comments
 (0)