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

use FileFormat::get_ext as the default file extension filter #12417

Merged
merged 2 commits into from
Sep 15, 2024

Conversation

waruto210
Copy link
Contributor

Which issue does this PR close?

Closes #12378.

Rationale for this change

Using FileFormat::get_ext as the default file extension filter better meets user expectations.

What changes are included in this PR?

Use FileFormat::get_ext as the default file extension filter

Are these changes tested?

Yes

Are there any user-facing changes?

User do not need to specify the file extension if they choose the default value.

@github-actions github-actions bot added the core Core DataFusion crate label Sep 10, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @waruto210 -- this makes sense to me and I think is a nice improvement.

I have a small API improvement suggestion, but I think we can do it as a follow on PR if you prefer.

Thanks again!

) -> Result<()> {
let ctx = SessionContext::new();
register_test_store(&ctx, &files.iter().map(|f| (*f, 10)).collect::<Vec<_>>());

let format = AvroFormat {};

let opt = ListingOptions::new(Arc::new(format))
.with_file_extension("")
let mut opt = ListingOptions::new(Arc::new(format))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could make this a nicer API by adding with_file_extension_opt or something so this code could be like:

let opt = ListingOptions::new(Arc::new(format))
            .with_file_extension_opt(file_ext)
            .with_target_partitions(target_partitions);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we could make this a nicer API by adding with_file_extension_opt or something so this code could be like:

let opt = ListingOptions::new(Arc::new(format))
            .with_file_extension_opt(file_ext)
            .with_target_partitions(target_partitions);

I think your advice is great, I'm on vacation right now and I'll revise the code when I get back.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is a PR with the proposed API: #12461

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is a PR with the proposed API: #12461

I have modified the code according to this API.

@alamb alamb mentioned this pull request Sep 13, 2024
3 tasks
@alamb
Copy link
Contributor

alamb commented Sep 13, 2024

BTW I am holding off on merging this PR until we cut the 42 release candidate to avoid introducing last minute behavior changes

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @waruto210 -- this is great. 🚀

@alamb alamb merged commit 3ac92ad into apache:main Sep 15, 2024
24 checks passed
@waruto210 waruto210 deleted the use_defeault_ext_filter branch September 15, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using the FileFormat::get_ext when creating ListingOptions
2 participants