Skip to content

Commit b59d8ca

Browse files
committed
merge logic in one func
1 parent f9a5eb5 commit b59d8ca

File tree

1 file changed

+4
-3
lines changed
  • datafusion/src/datasource/object_store

1 file changed

+4
-3
lines changed

datafusion/src/datasource/object_store/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub trait ObjectStore: Sync + Send + Debug {
141141
let suffix = suffix.to_owned();
142142
Ok(Box::pin(file_stream.filter(move |fr| {
143143
let has_suffix = match fr {
144-
Ok(f) => f.path().ends_with(&suffix) && !should_filter_out(f.path()),
144+
Ok(f) => do_path_filter_with_suffix(f.path(), &suffix),
145145
Err(_) => true,
146146
};
147147
async move { has_suffix }
@@ -161,12 +161,13 @@ pub trait ObjectStore: Sync + Send + Debug {
161161
}
162162
/// Checks if we should filter out this path name
163163
/// https://github.com/apache/spark/blob/5b91381b9bcea27b7be6d9cef852efbd6c23d98a/core/src/main/scala/org/apache/spark/util/HadoopFSUtils.scala#L358
164-
fn should_filter_out(path: &str) -> bool {
164+
fn do_path_filter_with_suffix(path: &str, suffix: &str) -> bool {
165165
let exclude = path.starts_with('_') && !path.contains('=')
166166
|| path.starts_with('.')
167167
|| path.ends_with("._COPYING_");
168168
let include = path.starts_with("_common_metadata") || path.starts_with("_metadata");
169-
exclude && !include
169+
let is_suffix = path.ends_with(suffix);
170+
(!exclude || include) && is_suffix
170171
}
171172

172173
static LOCAL_SCHEME: &str = "file";

0 commit comments

Comments
 (0)