Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python][FlightRPC] How to Extend PyArrow Flight Server with Custom RPCs? #45761

Open
amitbar101 opened this issue Mar 13, 2025 · 2 comments
Open

Comments

@amitbar101
Copy link

amitbar101 commented Mar 13, 2025

Describe the usage question you have. Please include as many useful details as possible.

I'm using a Python Flight server which comes with the built-in RPCs which defined at the Flight.proto file.

However, I want to add a new RPC similar to DoGet, but with a different return type.
For example:

rpc DoGet(Ticket) returns (FlightData) {}

Unlike DoGet, this RPC does not return a stream but a single FlightData message.

I found a C++ example that registers a gRPC service alongside a Flight service, allowing both to be accessed on the same port. However, my goal is to integrate a new RPC directly into the Flight server rather than serve two separate services at different threads.

  • It is possible to modify or extend the FlightServerBase to support a new RPC while keeping it part of the Flight protocol?
  • If not, is the only way to achieve this by running it separately, like in the C++ example? What are the consequences of implementing it this way (serving each server on different threads)?

I’d appreciate any guidance on the best approach for achieving this in Python. Are there any examples or best practices to follow?

Thanks!

Component(s)

Python, FlightRPC

@amitbar101 amitbar101 added the Type: usage Issue is a user question label Mar 13, 2025
@amitbar101 amitbar101 changed the title How to Extend PyArrow Flight Server with Custom RPCs? [FlightRPC][Python]How to Extend PyArrow Flight Server with Custom RPCs? Mar 13, 2025
@lidavidm
Copy link
Member

lidavidm commented Mar 13, 2025

This is a pain point that I have wanted to solve for a long time, but couldn't convince other contributors that it's worthwhile. Basically you can't do it. (You could use DoAction but that also returns a stream, and there's a proposal for adding data to GetFlightInfo that went nowhere.) Your only way is to just define your own gRPC service and not use Flight.

(Note that this won't work even if it were possible because FlightData encodes a single IPC message and you generally need two: one for the schema, one for the record batch - unless you transferred the schema (and any dictionary batches) separately)

@amitbar101 amitbar101 changed the title [FlightRPC][Python]How to Extend PyArrow Flight Server with Custom RPCs? [Python][FlightRPC] How to Extend PyArrow Flight Server with Custom RPCs? Mar 13, 2025
@lidavidm
Copy link
Member

You may want to watch #41840.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants