You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "kumarUjjawal (via GitHub)" <gi...@apache.org> on 2026/07/09 03:36:23 UTC
[PR] fix: avoid full listings for cached pruned partitions [datafusion]
kumarUjjawal opened a new pull request, #23402:
URL: https://github.com/apache/datafusion/pull/23402
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #23341.
## Rationale for this change
The list files cache currently performs a full table listing on a cold cache miss, even when partition pruning has already narrowed the scan to a specific path prefix.
This makes selective partition queries pay the cost of listing the full table unless users disable the cache.
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
- List only the requested prefix on cold list-cache misses.
- Keep using full-table cache entries to serve later prefix queries.
- Ensure prefix-scoped cache entries do not satisfy full-table lookups.
- Invalidate matching prefix-scoped list-cache entries on table writes.
- Add regression tests that check the actual object store list prefix.
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
Yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
Partition-pruned listing table queries with the list files cache enabled avoid full table listings on cold cache misses.
No API Change
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid full listings for cached pruned partitions [datafusion]
Posted by "kumarUjjawal (via GitHub)" <gi...@apache.org>.
kumarUjjawal commented on PR #23402:
URL: https://github.com/apache/datafusion/pull/23402#issuecomment-5814588858
Thank you @kosiew for taking another look.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid full listings for cached pruned partitions [datafusion]
Posted by "kumarUjjawal (via GitHub)" <gi...@apache.org>.
kumarUjjawal merged PR #23402:
URL: https://github.com/apache/datafusion/pull/23402
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid full listings for cached pruned partitions [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew commented on code in PR #23402:
URL: https://github.com/apache/datafusion/pull/23402#discussion_r4081239887
##########
datafusion/datasource/src/url.rs:
##########
@@ -399,29 +393,32 @@ async fn list_with_cache<'b>(
.map(|res| res.map_err(|e| DataFusionError::ObjectStore(Box::new(e))))
.boxed()),
Some(cache) => {
- // Build the filter prefix (only Some if prefix was requested)
let filter_prefix = prefix.is_some().then(|| full_prefix.clone());
let table_scoped_base_path = TableScopedPath {
table: table_ref.cloned(),
path: table_base_path.clone(),
};
+ let table_scoped_list_path = TableScopedPath {
Review Comment:
Optional extra coverage: it might be useful to cache `region=US/q1` first, then request `region=US` when another file also exists under that prefix. The existing prefix-to-root test exercises the same lookup branch, so I don't think this is blocking, but it could give us a little more confidence that a narrower cached prefix is never treated as satisfying a broader request.
##########
datafusion/catalog-listing/src/table.rs:
##########
@@ -823,11 +823,21 @@ impl ListingTable {
// Invalidate cache entries for this table if they exist
if let Some(lfc) = state.runtime_env().cache_manager.get_list_files_cache() {
- let key = TableScopedPath {
- table: table_path.get_table_ref().clone(),
- path: table_path.prefix().clone(),
- };
- let _ = lfc.remove(&key);
+ if let Some(table_ref) = table_path.get_table_ref() {
+ lfc.drop_table_entries(table_ref)?;
+ } else {
+ let table_prefix = table_path.prefix();
+ let keys: Vec<_> = lfc
+ .list_entries()
+ .into_keys()
+ .filter(|key| {
+ key.table.is_none() && key.path.prefix_matches(table_prefix)
Review Comment:
I think there is still a stale-cache case here for overlapping unscoped `ListingTable`s. We currently remove entries at or below the written table's prefix, but not an ancestor entry.
For example, suppose `table/` is cached, then we insert through an unscoped table rooted at `table/region=US/`. A later scan through `table/` will check its cached base entry first, so it can miss the newly inserted file. An insert through the same `table/` URL is fine because `prefix_matches` includes equality.
Could we invalidate unscoped cache entries whose paths overlap the written prefix in both directions, and add a regression test for the root-table/child-table case?
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid full listings for cached pruned partitions [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #23402:
URL: https://github.com/apache/datafusion/pull/23402#issuecomment-5003596205
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/23402?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `86.60714%` with `15 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 80.67%. Comparing base ([`1e58928`](https://app.codecov.io/gh/apache/datafusion/commit/1e589287c3d6bcf3bc6fa897bb889a6012e1d229?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5c8fcd3`](https://app.codecov.io/gh/apache/datafusion/commit/5c8fcd3ebfd575fa5e928a05a03e306fb5d35aec?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/23402?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [datafusion/datasource/src/url.rs](https://app.codecov.io/gh/apache/datafusion/pull/23402?src=pr&el=tree&filepath=datafusion%2Fdatasource%2Fsrc%2Furl.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9kYXRhc291cmNlL3NyYy91cmwucnM=) | 88.99% | [0 Missing and 12 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/23402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [datafusion/catalog-listing/src/table.rs](https://app.codecov.io/gh/apache/datafusion/pull/23402?src=pr&el=tree&filepath=datafusion%2Fcatalog-listing%2Fsrc%2Ftable.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9jYXRhbG9nLWxpc3Rpbmcvc3JjL3RhYmxlLnJz) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/23402?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #23402 +/- ##
==========================================
- Coverage 80.67% 80.67% -0.01%
==========================================
Files 1086 1086
Lines 366800 366897 +97
Branches 366800 366897 +97
==========================================
+ Hits 295912 295985 +73
- Misses 53260 53267 +7
- Partials 17628 17645 +17
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/23402?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid full listings for cached pruned partitions [datafusion]
Posted by "kumarUjjawal (via GitHub)" <gi...@apache.org>.
kumarUjjawal commented on PR #23402:
URL: https://github.com/apache/datafusion/pull/23402#issuecomment-5795171947
Thank you @kosiew
Addressed review items [d45941f](https://github.com/apache/datafusion/pull/23402/commits/d45941f1a7723f23f79ad65e17e8faec6056a026)
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org