Open alamb opened 9 months ago
SGTM
We should add flags in (the awkwardly named) SqlInfo to indicate support for these as we did with other new features
+1 and I agree with @lidavidm that we should add flags to SqlInfo
I have started looking into implementing this on the Go client side, and I'm running into some difficulties. Namely, the existing interface for PreparedStatement.Execute
returns a *FlightInfo
, but DoExchange
skips GetFlightInfo
altogether. The Rust client also presents a similar interface, and I would guess that most clients in other languages do the same.
Of course, one can always drop down to raw Flight/FlightSQL calls without using the abstraction of prepared statement "handles", but this just moves complexity to consumers of the library and makes me worry if the DoExchange
protocol for prepared statements will actually be adopted in the ecosystem.
So we have a few options:
PreparedStatement.Execute
to fetch the flight streams instead of just returning the FlightInfo
PreparedStatement.DoExchange
method, separate from the existing Execute
implementation that uses DoPut
@alamb do you have any thoughts on this?
@suremarc can you remind me why we would need to pass a FlightInfo
? I think we could send the required information as part of the payload of the stream, right?
For example
Sends a stream of FlightData
https://github.com/apache/arrow/blob/aded7bf37686a16fc4b0649ab97231427a219d7b/format/Flight.proto#L495-L520
And the FlightData:: flight_descriptor
field has the embedded cmd message (in which FlightSQL messages are embedded)
https://github.com/apache/arrow/blob/aded7bf37686a16fc4b0649ab97231427a219d7b/format/Flight.proto#L310
FYI @kallisti-dev who is also working on stateless prepared statement execution
@alamb I think we are on the same page that DoExchange
does not require passing a FlightInfo
— the problem is that the existing prepared statement interfaces do require returning a FlightInfo
back to the client. Introducing the DoExchange
protocol breaks this assumption.
For example, see the Go prepared statement implementation: PreparedStatement.Execute
, which returns a FlightInfo
. The Rust FlightSQL client does this too.
How about just returning null
or an empty FlightInfo
(no endpoint)?
Ah, we may want to return *flight.Reader
like Client.DoGet()
for DoExchange
version.
@alamb I think we are on the same page that DoExchange does not require passing a FlightInfo — the problem is that the existing prepared statement interfaces do require returning a FlightInfo back to the client. Introducing the DoExchange protocol breaks this assumption.
I always think of FlightInfo
as a source of potential indirection (as it can contain endpoint information so the subsequent call may be to a different endpoint / hostname)
Thus if there is no subsequent calls (just DoExchange
instead of DoPut/GetFlightInfo/DoGet
) the lack of FlightInfo
makes sense to me (as DoExchange
starts feeding back data from whatever endpoint you sent data to)
Describe the enhancement requested
As suggested by @kou on https://github.com/apache/arrow/issues/37720#issuecomment-1720662204
Usecase
Background
Currently FlightSQL requires three messages to run a prepared statement.
DoPut
, then aGetFlightInfo
and then aDoGet
:Proposal
By supporting
DoExchange
instead ofDoPut
+GetFlightInfo
+DoGet
only a single round trip is needed:Benefits:
Drawbacks:
Component(s)
FlightRPC