alamb commented on code in PR #9207:
URL: https://github.com/apache/arrow-datafusion/pull/9207#discussion_r1489330916
##########
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
Review Comment:
Now that you have added the unit test coverage I think it would be fine to
change. You could also do as a follow on PR if you prefer
--
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]