Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2393: Support glob patterns for files #2394

Merged
merged 27 commits into from
May 5, 2022
Merged

Issue 2393: Support glob patterns for files #2394

merged 27 commits into from
May 5, 2022

Conversation

timvw
Copy link
Contributor

@timvw timvw commented Apr 30, 2022

Which issue does this PR close?

Closes #2393.

What changes are included in this PR?

When the provided prefix is not a valid path (file/directory), we will now attempt to "glob" over the prefix.

Eg: when the path is
/testdata/blah.txt -> return /testdata/blah.txt (as before)
/testdata -> return all files that exist in /testdata (as before)
/testdata/x_z -> return all files that match the given pattern (assuming that there is no file/directory '/testdata/x_z')

@timvw timvw marked this pull request as ready for review April 30, 2022 22:38
@timvw timvw changed the title Issue 2393 Issue 2393: Support glob patterns for (local) file(s) Apr 30, 2022
@timvw
Copy link
Contributor Author

timvw commented May 1, 2022

Resolved failing clippy, lint and cargo fmt errors

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label May 1, 2022
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @timvw! The changes look reasonable to me.

@tustvold
Copy link
Contributor

tustvold commented May 1, 2022

Not had time to look in detail, but I think the code now mixes blocking IO, as performed by glob, and non-blocking IO as performed by tokio::fs. I think we should consistently use one or the other...

Perhaps we could use tokio::spawn_blocking if a runtime is available, and then use blocking IO within the closure (this is what tokio::fs does under the hood anyway). Perhaps checkout ParquetExec for an example of this?

@timvw
Copy link
Contributor Author

timvw commented May 1, 2022

Had a look at the implementation of tokio fs operations, and copied their (non-public) asyncify method to run the globbing on...

@timvw timvw marked this pull request as draft May 2, 2022 15:16
@timvw timvw changed the title Issue 2393: Support glob patterns for (local) file(s) Issue 2393: Support glob patterns for files May 3, 2022
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liking where this is headed 👍

data-access/src/object_store/mod.rs Outdated Show resolved Hide resolved
data-access/src/object_store/mod.rs Outdated Show resolved Hide resolved
@timvw timvw marked this pull request as ready for review May 3, 2022 14:43
@timvw
Copy link
Contributor Author

timvw commented May 3, 2022

Afaik this should be good to go now.

@timvw
Copy link
Contributor Author

timvw commented May 4, 2022

Tests pass now on my windows machine as well :)

@github-actions github-actions bot added the development-process Related to development process of DataFusion label May 4, 2022
@timvw
Copy link
Contributor Author

timvw commented May 4, 2022

Fixed clippy issues + documented the checks that are executed during a PR build (+ added script to execute them).

data-access/src/object_store/mod.rs Outdated Show resolved Hide resolved
dev/pr-checks.sh Outdated Show resolved Hide resolved
dev/pr-checks.sh Outdated Show resolved Hide resolved
data-access/src/object_store/mod.rs Outdated Show resolved Hide resolved
data-access/src/object_store/mod.rs Show resolved Hide resolved
@tustvold
Copy link
Contributor

tustvold commented May 4, 2022

Perhaps we could split out the formatting and CI changes into a separate PR, as I think they're someone parallel to the changes in this PR?

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you 👍, one minor nit which you can take or leave, will merge tomorrow unless anyone else weighs in.

Edit: also appears to be a merge conflict

/// Filters the file_stream to only contain files that end with suffix
fn filter_suffix(file_stream: FileMetaStream, suffix: &str) -> Result<FileMetaStream> {
let suffix = suffix.to_owned();
Ok(Box::pin(file_stream.filter(move |fr| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the code that was already in place.

When I update the code to use try_filter, it will not pass-through the errors anymore (not sure if anyone was actually doing something with them though..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased to handle the merge conflict

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will not pass-through the errors anymore

It should do? "All errors are passed through without filtering in this combinator."

data-access/src/object_store/mod.rs Outdated Show resolved Hide resolved
@tustvold tustvold added the api change Changes the API exposed to users of the crate label May 4, 2022
@tustvold tustvold merged commit fbeb726 into apache:master May 5, 2022
@tustvold
Copy link
Contributor

tustvold commented May 5, 2022

Thanks again 👍

@timvw timvw deleted the ISSUE-2393 branch May 5, 2022 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate datafusion Changes in the datafusion crate development-process Related to development process of DataFusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user to use glob/wildcard in file path
3 participants