You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Implement the statistics_cache function (#19054)
## 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#18953.
## Rationale for this change
Allow a way to check the contents of the file statistics 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?
<!--
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.
-->
- Added the `statistics_cache` function to `datafusion-cli`.
- Converted `FileStatisticsCache` to a trait and implemented the
`list_entries` method.
- Added unit tests.
## 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.
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
Yes, `FileStatisticsCache` has been changed to a trait. Previous
implementations need to implement the `list_entries` method.
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---------
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
// When the cache manager creates a StatisticsCache by default,
683
+
// the contents will show up here
684
+
let sql = "SELECT split_part(path, '/', -1) as filename, file_size_bytes, num_rows, num_columns, table_size_bytes from statistics_cache() order by filename";
685
+
let df = ctx.sql(sql).await?;
686
+
let rbs = df.collect().await?;
687
+
assert_snapshot!(batches_to_string(&rbs),@r"
688
+
++
689
+
++
690
+
");
691
+
692
+
Ok(())
693
+
}
694
+
695
+
// Can be removed when https://github.com/apache/datafusion/issues/19217 is resolved
let sql = "SELECT split_part(path, '/', -1) as filename, file_size_bytes, num_rows, num_columns, table_size_bytes from statistics_cache() order by filename";
0 commit comments