You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "bharath-techie (via GitHub)" <gi...@apache.org> on 2025/11/27 15:46:11 UTC
[PR] fix: pre-warm listing file statistics cache during listing table creation [datafusion]
bharath-techie opened a new pull request, #18971:
URL: https://github.com/apache/datafusion/pull/18971
Pre-warm listing file statistics cache during create listing table flow as suggested in https://github.com/apache/datafusion/issues/18952.
Reused `list_files_for_scan` to pre-warm.
## Which issue does this PR close?
https://github.com/apache/datafusion/issues/18952
<!--
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 #.
## Rationale for this change
<!--
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?
<!--
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?
<!--
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)?
-->
Yes unit tested.
## Are there any user-facing changes?
<!--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "bharath-techie (via GitHub)" <gi...@apache.org>.
bharath-techie commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3592310619
Hi @martin-g @alamb ,
Can you help decide following to move the PR forward ?
- The limit is based on number of rows, so we either we keep it as `None` or we make it configurable maybe ? If we are going to configuration route, I'm leaning towards keeping `None` as default as number of rows will vary based on data. Some users might have few columns, lots of rows and some vice versa.
- One use case is clickbench data, where we register partitions with ~99 million rows , and we want statistics of all files to be present for example.[ as given in parent issue https://github.com/apache/datafusion/issues/18952 ]
- Can you help decide whether to do this in background ? Doing it in sync path will be deterministic behavior I feel. Otherwise we need to update documentation to reflect the same.
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "bharath-techie (via GitHub)" <gi...@apache.org>.
bharath-techie commented on code in PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#discussion_r2569352707
##########
datafusion/core/src/datasource/listing_table_factory.rs:
##########
@@ -190,6 +190,12 @@ impl TableProviderFactory for ListingTableFactory {
.with_definition(cmd.definition.clone())
.with_constraints(cmd.constraints.clone())
.with_column_defaults(cmd.column_defaults.clone());
+
+ // Pre-warm statistics cache if collect_statistics is enabled
+ if session_state.config().collect_statistics() {
+ let _ = table.list_files_for_scan(state, &[], None).await?;
Review Comment:
1. Is it okay to reuse this method to pre-warm as we do couple more things post collecting the statistics ?
2. Also is no limit fine ? as list_file_statistics_cache doesn't seem to have any size limit unlike metadata cache ?
cc: @alamb
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#discussion_r2570027135
##########
datafusion/core/src/datasource/listing_table_factory.rs:
##########
@@ -190,6 +190,12 @@ impl TableProviderFactory for ListingTableFactory {
.with_definition(cmd.definition.clone())
.with_constraints(cmd.constraints.clone())
.with_column_defaults(cmd.column_defaults.clone());
+
+ // Pre-warm statistics cache if collect_statistics is enabled
+ if session_state.config().collect_statistics() {
+ let _ = table.list_files_for_scan(state, &[], None).await?;
Review Comment:
Should errors in the pre-warming be propagated ?
Maybe handle/ignore failures locally ?!
##########
datafusion/core/src/datasource/listing_table_factory.rs:
##########
@@ -190,6 +190,12 @@ impl TableProviderFactory for ListingTableFactory {
.with_definition(cmd.definition.clone())
.with_constraints(cmd.constraints.clone())
.with_column_defaults(cmd.column_defaults.clone());
+
+ // Pre-warm statistics cache if collect_statistics is enabled
+ if session_state.config().collect_statistics() {
+ let _ = table.list_files_for_scan(state, &[], None).await?;
Review Comment:
> 2\. Also is no limit fine ?
I think it should have a limit.
And maybe it should be done in the background.
If there are many files this may slow down things.
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3600251026
> is this something we should write down / document / implement? Maybe not the actual behavior of pre-fetching statistics in the background but some method or something to make it easier for others to call?
Yeah, I would open an issue for this later
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3603735465
> Thanks @alamb for the review and changes :)
>
> Also `listing file statistics cache` seems to not have any memory limit unlike `metadata cache` for example.
>
> Is that by design , do you think we need to add similar limit for this cache too ?
I think it is an oversight and we should add a similar limit. @nuno-faria actually asked the same question here:
- https://github.com/apache/datafusion/issues/18953#issuecomment-3593068416
I will file a subsequent ticket to track that as well
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3595963426
In our internal, we do stats collection in a separate task.
Background task is a good idea, but based on the current situation, the PR looks like the fastest way to have stats while creating table.
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "bharath-techie (via GitHub)" <gi...@apache.org>.
bharath-techie commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3600061959
Thanks @alamb for the review and changes :)
Also `listing file statistics cache` seems to not have any memory limit unlike `metadata cache` for example.
Is that by design , do you think we need to add similar limit for this cache too ?
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3603798101
Filed a ticket to track limiting the statistics cache:
- https://github.com/apache/datafusion/issues/19052
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #18971:
URL: https://github.com/apache/datafusion/pull/18971
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "bharath-techie (via GitHub)" <gi...@apache.org>.
bharath-techie commented on code in PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#discussion_r2570606415
##########
datafusion/core/src/datasource/listing_table_factory.rs:
##########
@@ -190,6 +190,12 @@ impl TableProviderFactory for ListingTableFactory {
.with_definition(cmd.definition.clone())
.with_constraints(cmd.constraints.clone())
.with_column_defaults(cmd.column_defaults.clone());
+
+ // Pre-warm statistics cache if collect_statistics is enabled
+ if session_state.config().collect_statistics() {
+ let _ = table.list_files_for_scan(state, &[], None).await?;
Review Comment:
Thanks @martin-g for reviewing.
Agree on having limit.
But doing it in background will result in inconsistent behavior ?
```
Should DataFusion collect statistics when first creating a table. Has no effect after the table is created. Applies to the default ListingTableProvider in DataFusion. Defaults to true.
```
Will a user not expect the statistics to be collected when creating the table and expect any query post that to be optimized based on that based on the above documentation ?
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "bharath-techie (via GitHub)" <gi...@apache.org>.
bharath-techie commented on code in PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#discussion_r2570606415
##########
datafusion/core/src/datasource/listing_table_factory.rs:
##########
@@ -190,6 +190,12 @@ impl TableProviderFactory for ListingTableFactory {
.with_definition(cmd.definition.clone())
.with_constraints(cmd.constraints.clone())
.with_column_defaults(cmd.column_defaults.clone());
+
+ // Pre-warm statistics cache if collect_statistics is enabled
+ if session_state.config().collect_statistics() {
+ let _ = table.list_files_for_scan(state, &[], None).await?;
Review Comment:
Thanks @martin-g for reviewing.
Agree on having limit.
But doing it in background will result in inconsistent behavior ?
```
Should DataFusion collect statistics when first creating a table. Has no effect after the table is created. Applies to the default ListingTableProvider in DataFusion. Defaults to true.
```
Will a user not expect the statistics to be collected when creating the table and expect any query post that to be optimized based on the above documentation ?
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3606889289
Thanks again @bharath-techie and @martin-g and @xudong963
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3593335500
Thank you @bharath-techie -- I am checking this one out
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3599145423
Thank you also @xudong963 and @martin-g for the reviews
> In our internal, we do stats collection in a separate task.
@xudong963 is this something we should write down / document / implement? Maybe not the actual behavior of pre-fetching statistics in the background but some method or something to make it easier for others to call?
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3599104203
I took the liberty of pushing some commits that fixed the CI failures and merging up from main
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3597363259
> My concern is that if there are _many_ files then the pre-warming of the cache may slow down the main operation. I am not sure how many is too many though.
>
> But I guess you could leave it as is for now and optimize it only after there is an evidence that it really causes slow downs for someone.
Thanks @martin-g -- I do agree that is a concern. However, I think the idea is that any subsequent query is going to collect the statistics anyways, so this PR simply moves which statement triggers the collection
--
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: pre-warm listing file statistics cache during listing table creation [datafusion]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on PR #18971:
URL: https://github.com/apache/datafusion/pull/18971#issuecomment-3592590670
My concern is that if there are _many_ files then the pre-warming of the cache may slow down the main operation. I am not sure how many is too many though.
But I guess you could leave it as is for now and optimize it only after there is an evidence that it really causes slow downs for someone.
--
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