Skip to content

Commit

Permalink
add unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jul 15, 2024
1 parent 4c2eb12 commit 23ddaf3
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions crates/polars-plan/src/plans/conversion/dsl_to_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,34 +716,40 @@ fn expand_scan_paths(
scan_type: &mut FileScan,
file_options: &mut FileScanOptions,
) -> PolarsResult<Arc<[PathBuf]>> {
#[allow(unused_mut)]
let mut lock = paths.lock().unwrap();

// Return if paths are already expanded
if lock.1 {
return Ok(lock.0.clone());
}

let paths_expanded = match scan_type {
#[cfg(feature = "parquet")]
FileScan::Parquet {
ref cloud_options, ..
} => expand_scan_paths_with_hive_update(&lock.0, file_options, cloud_options)?,
#[cfg(feature = "ipc")]
FileScan::Ipc {
ref cloud_options, ..
} => expand_scan_paths_with_hive_update(&lock.0, file_options, cloud_options)?,
#[cfg(feature = "csv")]
FileScan::Csv {
ref cloud_options, ..
} => expand_paths(&lock.0, file_options.glob, cloud_options.as_ref())?,
#[cfg(feature = "json")]
FileScan::NDJson { .. } => expand_paths(&lock.0, file_options.glob, None)?,
FileScan::Anonymous { .. } => lock.0.clone(), // Anonymous scans are already expanded.
};

*lock = (paths_expanded, true);

Ok(lock.0.clone())
{
let paths_expanded = match scan_type {
#[cfg(feature = "parquet")]
FileScan::Parquet {
ref cloud_options, ..
} => expand_scan_paths_with_hive_update(&lock.0, file_options, cloud_options)?,
#[cfg(feature = "ipc")]
FileScan::Ipc {
ref cloud_options, ..
} => expand_scan_paths_with_hive_update(&lock.0, file_options, cloud_options)?,
#[cfg(feature = "csv")]
FileScan::Csv {
ref cloud_options, ..
} => expand_paths(&lock.0, file_options.glob, cloud_options.as_ref())?,
#[cfg(feature = "json")]
FileScan::NDJson { .. } => expand_paths(&lock.0, file_options.glob, None)?,
FileScan::Anonymous { .. } => unreachable!(), // Invariant: Anonymous scans are already expanded.
};

#[allow(unreachable_code)]
{
*lock = (paths_expanded, true);

Ok(lock.0.clone())
}
}
}

/// Expand scan paths and update the Hive partition information of `file_options`.
Expand Down

0 comments on commit 23ddaf3

Please sign in to comment.