Expose ExecutionPlan statistics across the FFI boundary#22157
Open
mailmindlin wants to merge 9 commits into
Open
Expose ExecutionPlan statistics across the FFI boundary#22157mailmindlin wants to merge 9 commits into
ExecutionPlan statistics across the FFI boundary#22157mailmindlin wants to merge 9 commits into
Conversation
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
Not sure why it shows up on the FFI enum but not the original
97fb89e to
a171b9e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
ExecutionPlanstatistics across the FFI boundary #22152Rationale for this change
ExecutionPlan::partition_statisticsandTableProvider::statisticsare not currently transported across the DataFusion FFI boundary, so foreign plans and providers always reportStatistics::new_unknown/None. This blocks optimizer rules that depend on statistics (e.g. join reordering, partition pruning) from working with out-of-process plugins, which defeats the point of exposing those hooks to plugin authors.StatisticscontainsPrecision<ScalarValue>for column min/max/sum.ScalarValueis a large enum that's impractical to mirror in#[repr(C)], so I reuse the existingdatafusion_proto_common::Statisticsprost encoding — the same pattern this crate already uses for filter expressions.What changes are included in this PR?
datafusion_ffi::statisticsmodule with[de]serialize_statisticshelpers wrapping thedatafusion_proto_common::Statisticsround-trip.partition_statisticsfield onFFI_ExecutionPlanand correspondingExecutionPlan::partition_statisticsimpl onForeignExecutionPlanstatisticsfield onFFI_TableProviderand correspondingTableProvider::statisticsimpl onForeignTableProvider. Since the trait returnsOption<Statistics>, the implementation cannot propagate decode errors, it logs alog::warn!and triggers adebug_assert!.This PR is expected to be merged after #22136 so it includes those changes.
Are these changes tested?
Yes:
statistics.rscover three round-trip cases:Statistics::new_unknown, fully-exact statistics withScalarValue::Int32/Int64/Utf8min/max/sum, and mixedPrecision::Exact/Inexact/Absentvalues.execution_plan.rsexercisesForeignExecutionPlan::partition_statisticswith bothNoneandSome(idx)partitions, against a plan with no statistics (returnsStatistics::new_unknown) and a plan with concrete statistics.table_provider.rsuses a thinTableWithStatswrapper overMemTableto verify both theNonepath and the concreteStatisticspath throughForeignTableProvider::statistics.Are there any user-facing changes?
This is a breaking ABI change for the
datafusion-fficrate:FFI_ExecutionPlangains apartition_statisticsfield.FFI_TableProvidergains astatisticsfield.Plugins compiled against earlier versions of
datafusion-ffiwill need to be recompiled. There are no breaking changes to the Rust trait surface or toStatisticsitself; downstreamExecutionPlan/TableProviderimplementations require no changes.