Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix build while no-default-features enabled #442

Merged
merged 3 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
- name: Cargo sort
run: make cargo-sort


build:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions crates/iceberg/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
21 changes: 17 additions & 4 deletions crates/iceberg/src/io/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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),
Expand Down Expand Up @@ -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)?;

Expand All @@ -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();
Expand All @@ -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",
)),
}
}

Expand Down
10 changes: 10 additions & 0 deletions crates/iceberg/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum JoinHandle<T> {
Tokio(tokio::task::JoinHandle<T>),
#[cfg(all(feature = "async-std", not(feature = "tokio")))]
liurenjie1024 marked this conversation as resolved.
Show resolved Hide resolved
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> {
Expand All @@ -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")))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, which way does above refer to? This case returns unimplemented while no runtime has been enabled.

JoinHandle::Unimplemented(_) => unimplemented!("no runtime has been enabled"),
}
}
}
Expand All @@ -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")))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

unimplemented!("no runtime has been enabled")
}

#[allow(dead_code)]
Expand All @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

}

#[cfg(test)]
Expand Down
Loading