@@ -9,7 +9,7 @@ use crate::utils::require;
9
9
use crate :: {
10
10
DeltaResult , Engine , EngineData , Error , Expression , ExpressionRef , FileSystemClient , Version ,
11
11
} ;
12
- use itertools:: Itertools ;
12
+ use itertools:: { process_results , Itertools } ;
13
13
use std:: convert:: identity;
14
14
use std:: sync:: { Arc , LazyLock } ;
15
15
use tracing:: warn;
@@ -310,36 +310,25 @@ fn list_log_files_with_version(
310
310
// on config at some point
311
311
let mut commit_files = Vec :: with_capacity ( 10 ) ;
312
312
let mut checkpoint_parts = vec ! [ ] ;
313
- let mut max_checkpoint_version = start_version;
314
313
315
314
let log_files = list_log_files ( fs_client, log_root, start_version, end_version) ?;
316
315
317
- for ( version, files) in & log_files
318
- . filter_map ( |res| match res {
319
- Ok ( path) => Some ( path) ,
320
- Err ( e) => {
321
- warn ! ( "Error processing path: {:?}" , e) ;
322
- None
316
+ process_results ( log_files, |iter| {
317
+ let log_files = iter. chunk_by ( move |x| x. version ) ;
318
+ for ( version, files) in & log_files {
319
+ let mut new_checkpoint_parts = vec ! [ ] ;
320
+ for file in files {
321
+ if file. is_commit ( ) {
322
+ commit_files. push ( file) ;
323
+ } else if file. is_checkpoint ( ) {
324
+ new_checkpoint_parts. push ( file) ;
325
+ }
323
326
}
324
- } )
325
- . chunk_by ( |path| path. version )
326
- {
327
- let mut new_checkpoint_parts = vec ! [ ] ;
328
-
329
- for file in files {
330
- if file. is_commit ( ) {
331
- commit_files. push ( file) ;
332
- } else if file. is_checkpoint ( ) {
333
- new_checkpoint_parts. push ( file) ;
327
+ if validate_checkpoint_parts ( version, & new_checkpoint_parts) {
328
+ checkpoint_parts = new_checkpoint_parts;
334
329
}
335
330
}
336
- if validate_checkpoint_parts ( version, & new_checkpoint_parts)
337
- && ( max_checkpoint_version. is_none ( ) || Some ( version) >= max_checkpoint_version)
338
- {
339
- max_checkpoint_version = Some ( version) ;
340
- checkpoint_parts = new_checkpoint_parts;
341
- }
342
- }
331
+ } ) ?;
343
332
344
333
Ok ( ( commit_files, checkpoint_parts) )
345
334
}
@@ -385,10 +374,6 @@ fn list_log_files_with_checkpoint(
385
374
/// Validates that all the checkpoint parts belong to the same checkpoint version and that all parts
386
375
/// are present. Returns `true` if we have a complete checkpoint, `false` otherwise.
387
376
fn validate_checkpoint_parts ( version : u64 , checkpoint_parts : & [ ParsedLogPath ] ) -> bool {
388
- if checkpoint_parts. is_empty ( ) {
389
- return false ;
390
- }
391
-
392
377
match checkpoint_parts. last ( ) . map ( |file| & file. file_type ) {
393
378
Some ( LogPathFileType :: MultiPartCheckpoint { num_parts, .. } ) => {
394
379
if * num_parts as usize != checkpoint_parts. len ( ) {
@@ -411,8 +396,29 @@ fn validate_checkpoint_parts(version: u64, checkpoint_parts: &[ParsedLogPath]) -
411
396
return false ;
412
397
}
413
398
}
414
- // TODO: Include UuidCheckpoint once we actually support v2 checkpoints
415
- _ => { }
399
+ Some ( LogPathFileType :: UuidCheckpoint ( _) ) => {
400
+ warn ! (
401
+ "Found a UUID checkpoint at version {} when it is not supported" ,
402
+ version
403
+ ) ;
404
+ return false ;
405
+ }
406
+ Some ( LogPathFileType :: Commit ) | Some ( LogPathFileType :: CompactedCommit { .. } ) => {
407
+ warn ! (
408
+ "Found a commit file at version {} when expecting a checkpoint" ,
409
+ version
410
+ ) ;
411
+ return false ;
412
+ }
413
+ Some ( LogPathFileType :: Unknown ) => {
414
+ warn ! (
415
+ "Found an unknown file type at version {} when expecting a checkpoint" ,
416
+ version
417
+ ) ;
418
+ return false ;
419
+ }
420
+ // No checkpoint parts
421
+ None => return false ,
416
422
}
417
423
418
424
true
0 commit comments