Skip to content

Commit 58604ff

Browse files
committed
address pr reviews
1 parent e5b57e1 commit 58604ff

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

kernel/src/log_reader/manifest.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) struct ManifestPhase {
2222
sidecar_visitor: SidecarVisitor,
2323
log_root: Url,
2424
is_complete: bool,
25+
manifest_file: FileMeta,
2526
}
2627

2728
/// Possible transitions after ManifestPhase completes.
@@ -70,8 +71,7 @@ impl ManifestPhase {
7071
)?,
7172
extension => {
7273
return Err(Error::generic(format!(
73-
"Unsupported checkpoint extension: {}",
74-
extension
74+
"Unsupported checkpoint extension: {extension}",
7575
)));
7676
}
7777
};
@@ -82,6 +82,7 @@ impl ManifestPhase {
8282
sidecar_visitor: SidecarVisitor::default(),
8383
log_root,
8484
is_complete: false,
85+
manifest_file: manifest.location.clone(),
8586
})
8687
}
8788

@@ -94,7 +95,10 @@ impl ManifestPhase {
9495
pub(crate) fn finalize(self) -> DeltaResult<AfterManifest> {
9596
require!(
9697
self.is_complete,
97-
Error::generic("Finalize called on manifest reader but it was not exausted")
98+
Error::generic(format!(
99+
"Cannot finalize in-progress ManifestReader for file: {}",
100+
self.manifest_file.location
101+
))
98102
);
99103

100104
let sidecars: Vec<_> = self
@@ -117,10 +121,9 @@ impl Iterator for ManifestPhase {
117121

118122
fn next(&mut self) -> Option<Self::Item> {
119123
let result = self.actions.next().map(|batch_result| {
120-
batch_result.and_then(|batch| {
121-
self.sidecar_visitor.visit_rows_of(batch.actions())?;
122-
Ok(batch)
123-
})
124+
let batch = batch_result?;
125+
self.sidecar_visitor.visit_rows_of(batch.actions())?;
126+
Ok(batch)
124127
});
125128

126129
if result.is_none() {
@@ -134,12 +137,15 @@ impl Iterator for ManifestPhase {
134137
#[cfg(test)]
135138
mod tests {
136139
use super::*;
140+
use crate::arrow::array::{Array, StringArray, StructArray};
141+
use crate::engine::arrow_data::EngineDataArrowExt as _;
137142
use crate::utils::test_utils::{
138143
assert_result_error_with_message, create_engine_and_snapshot_from_path,
139144
load_extracted_test_table,
140145
};
141-
142146
use crate::SnapshotRef;
147+
148+
use itertools::Itertools;
143149
use std::sync::Arc;
144150
use test_utils::load_test_data;
145151

@@ -150,10 +156,6 @@ mod tests {
150156
expected_add_paths: &[&str],
151157
expected_sidecars: &[&str],
152158
) -> DeltaResult<()> {
153-
use crate::arrow::array::{Array, StringArray, StructArray};
154-
use crate::engine::arrow_data::EngineDataArrowExt as _;
155-
use itertools::Itertools;
156-
157159
let log_segment = snapshot.log_segment();
158160
let log_root = log_segment.log_root.clone();
159161
assert_eq!(log_segment.checkpoint_parts.len(), 1);
@@ -274,7 +276,10 @@ mod tests {
274276
)?;
275277

276278
let result = manifest_phase.finalize();
277-
assert_result_error_with_message(result, "not exausted");
279+
assert_result_error_with_message(
280+
result,
281+
"Cannot finalize in-progress ManifestReader for file",
282+
);
278283
Ok(())
279284
}
280285

0 commit comments

Comments
 (0)