esheppa commented on code in PR #9207:
URL: https://github.com/apache/arrow-datafusion/pull/9207#discussion_r1489309436
##########
datafusion/core/src/datasource/listing/url.rs:
##########
@@ -189,34 +190,39 @@ impl ListingTableUrl {
/// Returns `true` if `path` matches this [`ListingTableUrl`]
pub fn contains(&self, path: &Path, ignore_subdirectory: bool) -> bool {
- match self.strip_prefix(path) {
- Some(mut segments) => match &self.glob {
- Some(glob) => {
- if ignore_subdirectory {
- segments
- .next()
- .map_or(false, |file_name| glob.matches(file_name))
- } else {
- let stripped = segments.join("/");
- glob.matches(&stripped)
- }
+ let Some(all_segments) = self.strip_prefix(path) else {
+ return false;
+ };
+
+ // remove any segments that contain `=` as they are allowed even
+ // when ignore subdirectories is `true`.
+ let mut segments = all_segments.filter(|s| !s.contains('='));
+
+ match &self.glob {
+ Some(glob) => {
+ if ignore_subdirectory {
+ segments
+ .next()
+ .map_or(false, |file_name| glob.matches(file_name))
+ } else {
+ let stripped = segments.join(DELIMITER);
+ glob.matches(&stripped)
}
- None => {
- if ignore_subdirectory {
- let has_subdirectory =
segments.collect::<Vec<_>>().len() > 1;
- !has_subdirectory
- } else {
- true
- }
+ }
+ None => {
+ if ignore_subdirectory {
+ let has_subdirectory = segments.count() > 1;
+ !has_subdirectory
+ } else {
+ true
}
- },
- None => false,
+ }
}
}
/// Returns `true` if `path` refers to a collection of objects
pub fn is_collection(&self) -> bool {
- self.url.as_str().ends_with('/')
+ self.url.as_str().ends_with(DELIMITER)
}
Review Comment:
updated this to use the `DELIMITER` as elsewhere
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]