Skip to content

Add protobuf serialization/deserialization support for EmptyTable scans#20844

Open
OlegWock wants to merge 4 commits intoapache:mainfrom
OlegWock:add-protobuf-support-empty-table
Open

Add protobuf serialization/deserialization support for EmptyTable scans#20844
OlegWock wants to merge 4 commits intoapache:mainfrom
OlegWock:add-protobuf-support-empty-table

Conversation

@OlegWock
Copy link
Copy Markdown

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 EmptyTable as a base to bring schema to DF without any actual data. EmptyTable scans 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 EmptyTable to 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?

  • Moved EmptyTable from datafusion-core into datafusion-catalog and added backwards compatibility re-export (following pattern for other table providers moved earlier)
  • Added new EmptyTableScanNode to protobuf definitions
  • Added encoding and decoding for new entity into AsLogicalPlan for LogicalPlanNode implementation

Are these changes tested?

I added two roundtrip tests for the new node

Are there any user-facing changes?

EmptyTable can be imported from datafusion-catalog crate now, but old crate (datafusion-core) still re-exports it, so this shouldn't be breaking change

P.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

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.
@github-actions github-actions bot added core Core DataFusion crate catalog Related to the catalog crate proto Related to proto crate labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate core Core DataFusion crate proto Related to proto crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant