Add protobuf serialization/deserialization support for EmptyTable scans#20844
Open
OlegWock wants to merge 4 commits intoapache:mainfrom
Open
Add protobuf serialization/deserialization support for EmptyTable scans#20844OlegWock wants to merge 4 commits intoapache:mainfrom
EmptyTable scans#20844OlegWock wants to merge 4 commits intoapache:mainfrom
Conversation
Add two tests that verify EmptyTable cannot currently be serialized as part of a LogicalPlan TableScan via protobuf, confirming the need for built-in serialization support.
This enables datafusion-proto to reference EmptyTable directly for built-in protobuf serialization support. The old import path datafusion::datasource::empty::EmptyTable is preserved via re-export.
Add proto message for serializing TableScan nodes that reference an EmptyTable provider, and regenerate prost/pbjson code.
Add serialization and deserialization support for TableScan nodes that reference an EmptyTable provider, removing the need for a custom LogicalExtensionCodec.
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?
I figured it will be easier to submit PR right away as change doesn't look controversial. I'm happy to create an issue and link it here if you'd prefer.
Rationale for this change
So short story is: in another project we'd like to use DataFusion's to "build" operations on data and then submit resulting logical plan somewhere to execute (likely not using DF to actually execute the query). Since those plans never meant to be executed by DF we use
EmptyTableas a base to bring schema to DF without any actual data.EmptyTablescans not being serializable prevents us from sending those plans to Python or over the wire. I believe this change makes datafusion's LogicalPlan more portable and more usable outside of datafusion's query executor.Longer story: VegaFusion does server-side aggregation for Vega charts and is powered by DataFusion. We recently added option to use custom query/plan executors, which allows user to pass a schema (without data) to VegaFusion which will add all necessary aggregations (but not execute them) and return a logical plan to user. They can then outsource this plan to custom query executor (e.g. Spark). This is already implemented and works. However, since VegaFusion is most commonly used through Python bindings, we'd like to expose this API to Python too (and additionally as part of gPRC API too) , which requires serializing built plans to protobuf. Currently we use
EmptyTableto bring schema without any data to DataFusion. But since it can't be converted to protobuf, we're unable to expose this API. We considered providing custom decoder/encoder, but that would work only for gRPC case, but not Python as datafusion-python doesn't allow to provide custom decoder as far as I understand.What changes are included in this PR?
EmptyTablefromdatafusion-coreintodatafusion-catalogand added backwards compatibility re-export (following pattern for other table providers moved earlier)EmptyTableScanNodeto protobuf definitionsAsLogicalPlan for LogicalPlanNodeimplementationAre these changes tested?
I added two roundtrip tests for the new node
Are there any user-facing changes?
EmptyTablecan be imported fromdatafusion-catalogcrate now, but old crate (datafusion-core) still re-exports it, so this shouldn't be breaking changeP.S. Just to be explicit, code itself was written mostly by LLM (as I'm not that proficient in Rust yet). I did review and test it though