Skip to content

Commit 7931d85

Browse files
fix!: arrow and panic fixes (#903)
## What changes are proposed in this pull request? 1. README fixes to clarify new arrow semantics 2. default to arrow-55 in all cases except when user passes ONLY `arrow-54` 3. `insert_url_handler` returns `delta_kernel::Error` instead of `object_store::Error` and we return err instead of panic. ### This PR affects the following public APIs `insert_url_handler` returns `delta_kernel::Error` instead of `object_store::Error` ## How was this change tested? existing. `cargo tree` to check deps and manually verified that our code blows up if we remove `arrow-54` from `arrow_compat` and specify `arrow-54` flag (better testing coming later). --------- Co-authored-by: Ryan Johnson <[email protected]>
1 parent 8b71117 commit 7931d85

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ flags:
7979

8080
- `arrow-54`: Use arrow version 54
8181
- `arrow-55`: Use arrow version 55
82+
- `arrow`: Use the latest arrow version. Note that this is an _unstable_ flag: we will bump this to
83+
the latest arrow version at every arrow version release. Only removing old arrow versions will
84+
cause a breaking change for kernel. If you require a specific version N of arrow, you should
85+
specify it directly with `arrow-N`, e.g. `arrow-55`.
8286

83-
Note that if more than one `arrow-x` feature is enabled, kernel will default to the _lowest_
84-
specified flag. This also means that if you use `--all-features` you will get the lowest version of
87+
Note that if more than one `arrow-x` feature is enabled, kernel will use the _highest_ (latest)
88+
specified flag. This also means that if you use `--all-features` you will get the latest version of
8589
arrow that kernel supports.
8690

8791
If you enable at least one of `default-engine`, `sync-engine`, `arrow-conversion`, or
88-
`arrow-expression`, you must enable either `arrow` (we pick default version) or `arrow-54` or
92+
`arrow-expression`, you must enable either `arrow` (latest arrow version) or `arrow-54` or
8993
`arrow-55`.
9094

9195
### Object Store

kernel/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,20 @@ internal-api = []
104104
integration-test = ["hdfs-native-object-store/integration-test"]
105105

106106
# The default versions for arrow/parquet/object_store
107-
arrow = ["arrow-55"]
107+
arrow = ["arrow-55"] # latest arrow version
108+
need-arrow = [] # need-arrow is a marker that the feature needs arrow dep
108109
arrow-54 = ["dep:arrow_54", "dep:parquet_54", "dep:object_store_54"]
109110
arrow-55 = ["dep:arrow_55", "dep:parquet_55", "dep:object_store_55"]
110-
arrow-conversion = ["arrow"]
111-
arrow-expression = ["arrow"]
111+
arrow-conversion = ["need-arrow"]
112+
arrow-expression = ["need-arrow"]
112113

113114
# this is an 'internal' feature flag which has all the shared bits from default-engine and
114115
# default-engine-rustls
115116
default-engine-base = [
116117
"arrow-conversion",
117118
"arrow-expression",
118119
"futures",
119-
"arrow",
120+
"need-arrow",
120121
"tokio",
121122
]
122123
# the default-engine use the reqwest crate with default features which uses native-tls. if you want
@@ -128,7 +129,7 @@ default-engine-rustls = [
128129
"reqwest/http2",
129130
]
130131
sync-engine = [
131-
"arrow",
132+
"need-arrow",
132133
"tempfile",
133134
]
134135

kernel/src/arrow_compat.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
//! This module re-exports the different versions of arrow, parquet, and object_store we support.
22
3-
#[cfg(all(feature = "arrow-55", not(feature = "arrow-54")))]
4-
mod arrow_compat_shims {
5-
pub use arrow_55 as arrow;
6-
pub use object_store_55 as object_store;
7-
pub use parquet_55 as parquet;
8-
}
9-
10-
#[cfg(all(feature = "arrow-55", feature = "arrow-54"))]
3+
#[cfg(feature = "arrow-55")]
114
mod arrow_compat_shims {
125
pub use arrow_55 as arrow;
136
pub use object_store_55 as object_store;
@@ -24,7 +17,7 @@ mod arrow_compat_shims {
2417
// if nothing is enabled but we need arrow because of some other feature flag, throw compile-time
2518
// error
2619
#[cfg(all(
27-
feature = "arrow",
20+
feature = "need-arrow",
2821
not(feature = "arrow-54"),
2922
not(feature = "arrow-55")
3023
))]

kernel/src/engine/default/storage.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::object_store::path::Path;
33
use crate::object_store::{Error, ObjectStore};
44
use url::Url;
55

6+
use crate::Error as DeltaError;
67
use std::collections::HashMap;
78
use std::sync::{Arc, LazyLock, RwLock};
89

@@ -25,12 +26,13 @@ static URL_REGISTRY: LazyLock<RwLock<Handlers>> = LazyLock::new(|| RwLock::new(H
2526
pub fn insert_url_handler(
2627
scheme: impl AsRef<str>,
2728
handler_closure: HandlerClosure,
28-
) -> Result<(), Error> {
29-
if let Ok(mut lock) = URL_REGISTRY.write() {
30-
(*lock).insert(scheme.as_ref().into(), handler_closure);
31-
} else {
32-
panic!("Failed to acquire lock for adding a URL handler!");
33-
}
29+
) -> Result<(), DeltaError> {
30+
let Ok(mut registry) = URL_REGISTRY.write() else {
31+
return Err(DeltaError::generic(
32+
"failed to acquire lock for adding a URL handler!",
33+
));
34+
};
35+
registry.insert(scheme.as_ref().into(), handler_closure);
3436
Ok(())
3537
}
3638

0 commit comments

Comments
 (0)