OlegWock opened a new pull request, #20844:
URL: https://github.com/apache/datafusion/pull/20844
## 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.
-->
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
<!--
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.
-->
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](https://github.com/vega/vegafusion) does
server-side aggregation for Vega charts and is powered by DataFusion. We
recently added option to [use custom query/plan
executors](https://github.com/vega/vegafusion/pull/573), 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 a
s datafusion-python doesn't allow to provide custom decoder as far as I
understand.
## 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.
-->
* 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?
<!--
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)?
-->
I added two roundtrip tests for the new node
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
`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
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
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
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]