Arrow Flight RPC#

Arrow Flight is an RPC framework for high-performance data services based on Arrow data, and is built on top of gRPC and the IPC format.

Flight is organized around streams of Arrow record batches, being either downloaded from or uploaded to another service. A set of metadata methods offers discovery and introspection of streams, as well as the ability to implement application-specific methods.

Methods and message wire formats are defined by Protobuf, enabling interoperability with clients that may support gRPC and Arrow separately, but not Flight. However, Flight implementations include further optimizations to avoid overhead in usage of Protobuf (mostly around avoiding excessive memory copies).

RPC Methods and Request Patterns#

Flight defines a set of RPC methods for uploading/downloading data, retrieving metadata about a data stream, listing available data streams, and for implementing application-specific RPC methods. A Flight service implements some subset of these methods, while a Flight client can call any of these methods.

Data streams are identified by descriptors (the FlightDescriptor message), which are either a path or an arbitrary binary command. For instance, the descriptor may encode a SQL query, a path to a file on a distributed file system, or even a pickled Python object; the application can use this message as it sees fit.

Thus, one Flight client can connect to any service and perform basic operations. To facilitate this, Flight services are expected to support some common request patterns, described next. Of course, applications may ignore compatibility and simply treat the Flight RPC methods as low-level building blocks for their own purposes.

See Protocol Buffer Definitions for full details on the methods and messages involved.

Downloading Data#

A client that wishes to download the data would:

../_images/DoGet.mmd.svg

Retrieving data via DoGet.#

  1. Construct or acquire a FlightDescriptor for the data set they are interested in.

    A client may know what descriptor they want already, or they may use methods like ListFlights to discover them.

  2. Call GetFlightInfo(FlightDescriptor) to get a FlightInfo message.

    Flight does not require that data live on the same server as metadata. Hence, FlightInfo contains details on where the data is located, so the client can go fetch the data from an appropriate server. This is encoded as a series of FlightEndpoint messages inside FlightInfo. Each endpoint represents some location that contains a subset of the response data.

    An endpoint contains a list of locations (server addresses) where this data can be retrieved from, and a Ticket, an opaque binary token that the server will use to identify the data being requested.

    If FlightInfo.ordered is true, this signals there is some order between data from different endpoints. Clients should produce the same results as if the data returned from each of the endpoints was concatenated, in order, from front to back.

    If FlightInfo.ordered is false, the client may return data from any of the endpoints in arbitrary order. Data from any specific endpoint must be returned in order, but the data from different endpoints may be interleaved to allow parallel fetches.

    Note that since some clients may ignore FlightInfo.ordered, if ordering is important and client support cannot be ensured, servers should return a single endpoint.

    The response also contains other metadata, like the schema, and optionally an estimate of the dataset size.

  3. Consume each endpoint returned by the server.

    To consume an endpoint, the client should connect to one of the locations in the endpoint, then call DoGet(Ticket) with the ticket in the endpoint. This will give the client a stream of Arrow record batches.

    If the server wishes to indicate that the data is on the local server and not a different location, then it can return an empty list of locations. The client can then reuse the existing connection to the original server to fetch data. Otherwise, the client must connect to one of the indicated locations.

    In this way, the locations inside an endpoint can also be thought of as performing look-aside load balancing or service discovery functions. And the endpoints can represent data that is partitioned or otherwise distributed.

    The client must consume all endpoints to retrieve the complete data set. The client can consume endpoints in any order, or even in parallel, or distribute the endpoints among multiple machines for consumption; this is up to the application to implement. The client can also use FlightInfo.ordered. See the previous item for details of FlightInfo.ordered.

    Each endpoint may have expiration time (FlightEndpoint.expiration_time). If an endpoint has expiration time, the client can get data multiple times by DoGet until the expiration time is reached. Otherwise, it is application-defined whether DoGet requests may be retried. The expiration time is represented as google.protobuf.Timestamp.

    If the expiration time is short, the client may be able to extend the expiration time by RenewFlightEndpoint action. The client need to use DoAction with RenewFlightEndpoint action type to extend the expiration time. Action.body must be RenewFlightEndpointRequest that has FlightEndpoint to be renewed.

    The client may be able to cancel the returned FlightInfo by CancelFlightInfo action. The client need to use DoAction with CancelFlightInfo action type to cancel the FlightInfo.

Downloading Data by Running a Heavy Query#

A client may need to request a heavy query to download data. However, GetFlightInfo doesn’t return until the query completes, so the client is blocked. In this situation, the client can use PollFlightInfo instead of GetFlightInfo:

../_images/PollFlightInfo.mmd.svg

Polling a long-running query by PollFlightInfo.#

  1. Construct or acquire a FlightDescriptor, as before.

  2. Call PollFlightInfo(FlightDescriptor) to get a PollInfo message.

    A server should respond as quickly as possible on the first call. So the client shouldn’t wait for the first PollInfo response.

    If the query isn’t finished, PollInfo.flight_descriptor has a FlightDescriptor. The client should use the descriptor (not the original FlightDescriptor) to call the next PollFlightInfo(). A server should recognize a PollInfo.flight_descriptor that is not necessarily the latest in case the client misses an update in between.

    If the query is finished, PollInfo.flight_descriptor is unset.

    PollInfo.info is the currently available results so far. It’s a complete FlightInfo each time not just the delta between the previous and current FlightInfo. A server should only append to the endpoints in PollInfo.info each time. So the client can run DoGet(Ticket) with the Ticket in the PollInfo.info even when the query isn’t finished yet. FlightInfo.ordered is also valid.

    A server should not respond until the result would be different from last time. That way, the client can “long poll” for updates without constantly making requests. Clients can set a short timeout to avoid blocking calls if desired.

    PollInfo.progress may be set. It represents progress of the query. If it’s set, the value must be in [0.0, 1.0]. The value is not necessarily monotonic or nondecreasing. A server may respond by only updating the PollInfo.progress value, though it shouldn’t spam the client with updates.

    PollInfo.timestamp is the expiration time for this request. After this passes, a server might not accept the poll descriptor anymore and the query may be cancelled. This may be updated on a call to PollFlightInfo. The expiration time is represented as google.protobuf.Timestamp.

    A client may be able to cancel the query by the CancelFlightInfo action.

    A server should return an error status instead of a response if the query fails. The client should not poll the request except for TIMED_OUT and UNAVAILABLE, which may not originate from the server.

  3. Consume each endpoint returned by the server, as before.

Uploading Data#

To upload data, a client would:

../_images/DoPut.mmd.svg

Uploading data via DoPut.#

  1. Construct or acquire a FlightDescriptor, as before.

  2. Call DoPut(FlightData) and upload a stream of Arrow record batches.

    The FlightDescriptor is included with the first message so the server can identify the dataset.

DoPut allows the server to send response messages back to the client with custom metadata. This can be used to implement things like resumable writes (e.g. the server can periodically send a message indicating how many rows have been committed so far).

Exchanging Data#

Some use cases may require uploading and downloading data within a single call. While this can be emulated with multiple calls, this may be difficult if the application is stateful. For instance, the application may wish to implement a call where the client uploads data and the server responds with a transformation of that data; this would require being stateful if implemented using DoGet and DoPut. Instead, DoExchange allows this to be implemented as a single call. A client would:

../_images/DoExchange.mmd.svg

Complex data flow with DoExchange.#

  1. Construct or acquire a FlightDescriptor, as before.

  2. Call DoExchange(FlightData).

    The FlightDescriptor is included with the first message, as with DoPut. At this point, both the client and the server may simultaneously stream data to the other side.

Authentication#

Flight supports a variety of authentication methods that applications can customize for their needs.

“Handshake” authentication

This is implemented in two parts. At connection time, the client calls the Handshake RPC method, and the application-defined authentication handler can exchange any number of messages with its counterpart on the server. The handler then provides a binary token. The Flight client will then include this token in the headers of all future calls, which is validated by the server authentication handler.

Applications may use any part of this; for instance, they may ignore the initial handshake and send an externally acquired token (e.g. a bearer token) on each call, or they may establish trust during the handshake and not validate a token for each call, treating the connection as stateful (a “login” pattern).

Warning

Unless a token is validated on every call, this pattern is not secure, especially in the presence of a layer 7 load balancer, as is common with gRPC, or if gRPC transparently reconnects the client.

Header-based/middleware-based authentication

Clients may include custom headers with calls. Custom middleware can then be implemented to validate and accept/reject calls on the server side.

Mutual TLS (mTLS)

The client provides a certificate during connection establishment which is verified by the server. The application does not need to implement any authentication code, but must provision and distribute certificates.

This may only be available in certain implementations, and is only available when TLS is also enabled.

Some Flight implementations may expose the underlying gRPC API as well, in which case any authentication method supported by gRPC is available.

Transport Implementations#

Flight is primarily defined in terms of its Protobuf and gRPC specification below, but Arrow implementations may also support alternative transports (see Flight RPC). In that case, implementations should use the following URI schemes for the given transport implementations:

Transport

URI Scheme

gRPC (plaintext)

grpc: or grpc+tcp:

gRPC (TLS)

grpc+tls:

gRPC (Unix domain socket)

grpc+unix:

UCX (plaintext)

ucx:

Error Handling#

Arrow Flight defines its own set of error codes. The implementation differs between languages (e.g. in C++, Unimplemented is a general Arrow error status while it’s a Flight-specific exception in Java), but the following set is exposed:

Error Code

Description

UNKNOWN

An unknown error. The default if no other error applies.

INTERNAL

An error internal to the service implementation occurred.

INVALID_ARGUMENT

The client passed an invalid argument to the RPC.

TIMED_OUT

The operation exceeded a timeout or deadline.

NOT_FOUND

The requested resource (action, data stream) was not found.

ALREADY_EXISTS

The resource already exists.

CANCELLED

The operation was cancelled (either by the client or the server).

UNAUTHENTICATED

The client is not authenticated.

UNAUTHORIZED

The client is authenticated, but does not have permissions for the requested operation.

UNIMPLEMENTED

The RPC is not implemented.

UNAVAILABLE

The server is not available. May be emitted by the client for connectivity reasons.

External Resources#

Protocol Buffer Definitions#

  1/*
  2 * Licensed to the Apache Software Foundation (ASF) under one
  3 * or more contributor license agreements.  See the NOTICE file
  4 * distributed with this work for additional information
  5 * regarding copyright ownership.  The ASF licenses this file
  6 * to you under the Apache License, Version 2.0 (the
  7 * "License"); you may not use this file except in compliance
  8 * with the License.  You may obtain a copy of the License at
  9 * <p>
 10 * http://www.apache.org/licenses/LICENSE-2.0
 11 * <p>
 12 * Unless required by applicable law or agreed to in writing, software
 13 * distributed under the License is distributed on an "AS IS" BASIS,
 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15 * See the License for the specific language governing permissions and
 16 * limitations under the License.
 17 */
 18
 19syntax = "proto3";
 20import "google/protobuf/timestamp.proto";
 21
 22option java_package = "org.apache.arrow.flight.impl";
 23option go_package = "github.com/apache/arrow/go/arrow/flight/gen/flight";
 24option csharp_namespace = "Apache.Arrow.Flight.Protocol";
 25
 26package arrow.flight.protocol;
 27
 28/*
 29 * A flight service is an endpoint for retrieving or storing Arrow data. A
 30 * flight service can expose one or more predefined endpoints that can be
 31 * accessed using the Arrow Flight Protocol. Additionally, a flight service
 32 * can expose a set of actions that are available.
 33 */
 34service FlightService {
 35
 36  /*
 37   * Handshake between client and server. Depending on the server, the
 38   * handshake may be required to determine the token that should be used for
 39   * future operations. Both request and response are streams to allow multiple
 40   * round-trips depending on auth mechanism.
 41   */
 42  rpc Handshake(stream HandshakeRequest) returns (stream HandshakeResponse) {}
 43
 44  /*
 45   * Get a list of available streams given a particular criteria. Most flight
 46   * services will expose one or more streams that are readily available for
 47   * retrieval. This api allows listing the streams available for
 48   * consumption. A user can also provide a criteria. The criteria can limit
 49   * the subset of streams that can be listed via this interface. Each flight
 50   * service allows its own definition of how to consume criteria.
 51   */
 52  rpc ListFlights(Criteria) returns (stream FlightInfo) {}
 53
 54  /*
 55   * For a given FlightDescriptor, get information about how the flight can be
 56   * consumed. This is a useful interface if the consumer of the interface
 57   * already can identify the specific flight to consume. This interface can
 58   * also allow a consumer to generate a flight stream through a specified
 59   * descriptor. For example, a flight descriptor might be something that
 60   * includes a SQL statement or a Pickled Python operation that will be
 61   * executed. In those cases, the descriptor will not be previously available
 62   * within the list of available streams provided by ListFlights but will be
 63   * available for consumption for the duration defined by the specific flight
 64   * service.
 65   */
 66  rpc GetFlightInfo(FlightDescriptor) returns (FlightInfo) {}
 67
 68  /*
 69   * For a given FlightDescriptor, start a query and get information
 70   * to poll its execution status. This is a useful interface if the
 71   * query may be a long-running query. The first PollFlightInfo call
 72   * should return as quickly as possible. (GetFlightInfo doesn't
 73   * return until the query is complete.)
 74   *
 75   * A client can consume any available results before
 76   * the query is completed. See PollInfo.info for details.
 77   *
 78   * A client can poll the updated query status by calling
 79   * PollFlightInfo() with PollInfo.flight_descriptor. A server
 80   * should not respond until the result would be different from last
 81   * time. That way, the client can "long poll" for updates
 82   * without constantly making requests. Clients can set a short timeout
 83   * to avoid blocking calls if desired.
 84   *
 85   * A client can't use PollInfo.flight_descriptor after
 86   * PollInfo.expiration_time passes. A server might not accept the
 87   * retry descriptor anymore and the query may be cancelled.
 88   *
 89   * A client may use the CancelFlightInfo action with
 90   * PollInfo.info to cancel the running query.
 91   */
 92  rpc PollFlightInfo(FlightDescriptor) returns (PollInfo) {}
 93
 94  /*
 95   * For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema
 96   * This is used when a consumer needs the Schema of flight stream. Similar to
 97   * GetFlightInfo this interface may generate a new flight that was not previously
 98   * available in ListFlights.
 99   */
100   rpc GetSchema(FlightDescriptor) returns (SchemaResult) {}
101
102  /*
103   * Retrieve a single stream associated with a particular descriptor
104   * associated with the referenced ticket. A Flight can be composed of one or
105   * more streams where each stream can be retrieved using a separate opaque
106   * ticket that the flight service uses for managing a collection of streams.
107   */
108  rpc DoGet(Ticket) returns (stream FlightData) {}
109
110  /*
111   * Push a stream to the flight service associated with a particular
112   * flight stream. This allows a client of a flight service to upload a stream
113   * of data. Depending on the particular flight service, a client consumer
114   * could be allowed to upload a single stream per descriptor or an unlimited
115   * number. In the latter, the service might implement a 'seal' action that
116   * can be applied to a descriptor once all streams are uploaded.
117   */
118  rpc DoPut(stream FlightData) returns (stream PutResult) {}
119
120  /*
121   * Open a bidirectional data channel for a given descriptor. This
122   * allows clients to send and receive arbitrary Arrow data and
123   * application-specific metadata in a single logical stream. In
124   * contrast to DoGet/DoPut, this is more suited for clients
125   * offloading computation (rather than storage) to a Flight service.
126   */
127  rpc DoExchange(stream FlightData) returns (stream FlightData) {}
128
129  /*
130   * Flight services can support an arbitrary number of simple actions in
131   * addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut
132   * operations that are potentially available. DoAction allows a flight client
133   * to do a specific action against a flight service. An action includes
134   * opaque request and response objects that are specific to the type action
135   * being undertaken.
136   */
137  rpc DoAction(Action) returns (stream Result) {}
138
139  /*
140   * A flight service exposes all of the available action types that it has
141   * along with descriptions. This allows different flight consumers to
142   * understand the capabilities of the flight service.
143   */
144  rpc ListActions(Empty) returns (stream ActionType) {}
145}
146
147/*
148 * The request that a client provides to a server on handshake.
149 */
150message HandshakeRequest {
151
152  /*
153   * A defined protocol version
154   */
155  uint64 protocol_version = 1;
156
157  /*
158   * Arbitrary auth/handshake info.
159   */
160  bytes payload = 2;
161}
162
163message HandshakeResponse {
164
165  /*
166   * A defined protocol version
167   */
168  uint64 protocol_version = 1;
169
170  /*
171   * Arbitrary auth/handshake info.
172   */
173  bytes payload = 2;
174}
175
176/*
177 * A message for doing simple auth.
178 */
179message BasicAuth {
180  string username = 2;
181  string password = 3;
182}
183
184message Empty {}
185
186/*
187 * Describes an available action, including both the name used for execution
188 * along with a short description of the purpose of the action.
189 */
190message ActionType {
191  string type = 1;
192  string description = 2;
193}
194
195/*
196 * A service specific expression that can be used to return a limited set
197 * of available Arrow Flight streams.
198 */
199message Criteria {
200  bytes expression = 1;
201}
202
203/*
204 * An opaque action specific for the service.
205 */
206message Action {
207  string type = 1;
208  bytes body = 2;
209}
210
211/*
212 * The request of the CancelFlightInfo action.
213 *
214 * The request should be stored in Action.body.
215 */
216message CancelFlightInfoRequest {
217  FlightInfo info = 1;
218}
219
220/*
221 * The request of the RenewFlightEndpoint action.
222 *
223 * The request should be stored in Action.body.
224 */
225message RenewFlightEndpointRequest {
226  FlightEndpoint endpoint = 1;
227}
228
229/*
230 * An opaque result returned after executing an action.
231 */
232message Result {
233  bytes body = 1;
234}
235
236/*
237 * The result of a cancel operation.
238 *
239 * This is used by CancelFlightInfoResult.status.
240 */
241enum CancelStatus {
242  // The cancellation status is unknown. Servers should avoid using
243  // this value (send a NOT_FOUND error if the requested query is
244  // not known). Clients can retry the request.
245  CANCEL_STATUS_UNSPECIFIED = 0;
246  // The cancellation request is complete. Subsequent requests with
247  // the same payload may return CANCELLED or a NOT_FOUND error.
248  CANCEL_STATUS_CANCELLED = 1;
249  // The cancellation request is in progress. The client may retry
250  // the cancellation request.
251  CANCEL_STATUS_CANCELLING = 2;
252  // The query is not cancellable. The client should not retry the
253  // cancellation request.
254  CANCEL_STATUS_NOT_CANCELLABLE = 3;
255}
256
257/*
258 * The result of the CancelFlightInfo action.
259 *
260 * The result should be stored in Result.body.
261 */
262message CancelFlightInfoResult {
263  CancelStatus status = 1;
264}
265
266/*
267 * Wrap the result of a getSchema call
268 */
269message SchemaResult {
270  // The schema of the dataset in its IPC form:
271  //   4 bytes - an optional IPC_CONTINUATION_TOKEN prefix
272  //   4 bytes - the byte length of the payload
273  //   a flatbuffer Message whose header is the Schema
274  bytes schema = 1;
275}
276
277/*
278 * The name or tag for a Flight. May be used as a way to retrieve or generate
279 * a flight or be used to expose a set of previously defined flights.
280 */
281message FlightDescriptor {
282
283  /*
284   * Describes what type of descriptor is defined.
285   */
286  enum DescriptorType {
287
288    // Protobuf pattern, not used.
289    UNKNOWN = 0;
290
291    /*
292     * A named path that identifies a dataset. A path is composed of a string
293     * or list of strings describing a particular dataset. This is conceptually
294     *  similar to a path inside a filesystem.
295     */
296    PATH = 1;
297
298    /*
299     * An opaque command to generate a dataset.
300     */
301    CMD = 2;
302  }
303
304  DescriptorType type = 1;
305
306  /*
307   * Opaque value used to express a command. Should only be defined when
308   * type = CMD.
309   */
310  bytes cmd = 2;
311
312  /*
313   * List of strings identifying a particular dataset. Should only be defined
314   * when type = PATH.
315   */
316  repeated string path = 3;
317}
318
319/*
320 * The access coordinates for retrieval of a dataset. With a FlightInfo, a
321 * consumer is able to determine how to retrieve a dataset.
322 */
323message FlightInfo {
324  // The schema of the dataset in its IPC form:
325  //   4 bytes - an optional IPC_CONTINUATION_TOKEN prefix
326  //   4 bytes - the byte length of the payload
327  //   a flatbuffer Message whose header is the Schema
328  bytes schema = 1;
329
330  /*
331   * The descriptor associated with this info.
332   */
333  FlightDescriptor flight_descriptor = 2;
334
335  /*
336   * A list of endpoints associated with the flight. To consume the
337   * whole flight, all endpoints (and hence all Tickets) must be
338   * consumed. Endpoints can be consumed in any order.
339   *
340   * In other words, an application can use multiple endpoints to
341   * represent partitioned data.
342   *
343   * If the returned data has an ordering, an application can use
344   * "FlightInfo.ordered = true" or should return the all data in a
345   * single endpoint. Otherwise, there is no ordering defined on
346   * endpoints or the data within.
347   *
348   * A client can read ordered data by reading data from returned
349   * endpoints, in order, from front to back.
350   *
351   * Note that a client may ignore "FlightInfo.ordered = true". If an
352   * ordering is important for an application, an application must
353   * choose one of them:
354   *
355   * * An application requires that all clients must read data in
356   *   returned endpoints order.
357   * * An application must return the all data in a single endpoint.
358   */
359  repeated FlightEndpoint endpoint = 3;
360
361  // Set these to -1 if unknown.
362  int64 total_records = 4;
363  int64 total_bytes = 5;
364
365  /*
366   * FlightEndpoints are in the same order as the data.
367   */
368  bool ordered = 6;
369
370  /*
371   * Application-defined metadata.
372   * 
373   * There is no inherent or required relationship between this
374   * and the app_metadata fields in the FlightEndpoints or resulting
375   * FlightData messages. Since this metadata is application-defined,
376   * a given application could define there to be a relationship,
377   * but there is none required by the spec.
378   */
379  bytes app_metadata = 7;
380}
381
382/*
383 * The information to process a long-running query.
384 */
385message PollInfo {
386  /*
387   * The currently available results.
388   *
389   * If "flight_descriptor" is not specified, the query is complete
390   * and "info" specifies all results. Otherwise, "info" contains
391   * partial query results.
392   *
393   * Note that each PollInfo response contains a complete
394   * FlightInfo (not just the delta between the previous and current
395   * FlightInfo).
396   *
397   * Subsequent PollInfo responses may only append new endpoints to
398   * info.
399   *
400   * Clients can begin fetching results via DoGet(Ticket) with the
401   * ticket in the info before the query is
402   * completed. FlightInfo.ordered is also valid.
403   */
404  FlightInfo info = 1;
405
406  /*
407   * The descriptor the client should use on the next try.
408   * If unset, the query is complete.
409   */
410  FlightDescriptor flight_descriptor = 2;
411
412  /*
413   * Query progress. If known, must be in [0.0, 1.0] but need not be
414   * monotonic or nondecreasing. If unknown, do not set.
415   */
416  optional double progress = 3;
417
418  /*
419   * Expiration time for this request. After this passes, the server
420   * might not accept the retry descriptor anymore (and the query may
421   * be cancelled). This may be updated on a call to PollFlightInfo.
422   */
423  google.protobuf.Timestamp expiration_time = 4;
424}
425
426/*
427 * A particular stream or split associated with a flight.
428 */
429message FlightEndpoint {
430
431  /*
432   * Token used to retrieve this stream.
433   */
434  Ticket ticket = 1;
435
436  /*
437   * A list of URIs where this ticket can be redeemed via DoGet().
438   *
439   * If the list is empty, the expectation is that the ticket can only
440   * be redeemed on the current service where the ticket was
441   * generated.
442   *
443   * If the list is not empty, the expectation is that the ticket can
444   * be redeemed at any of the locations, and that the data returned
445   * will be equivalent. In this case, the ticket may only be redeemed
446   * at one of the given locations, and not (necessarily) on the
447   * current service.
448   *
449   * In other words, an application can use multiple locations to
450   * represent redundant and/or load balanced services.
451   */
452  repeated Location location = 2;
453
454  /*
455   * Expiration time of this stream. If present, clients may assume
456   * they can retry DoGet requests. Otherwise, it is
457   * application-defined whether DoGet requests may be retried.
458   */
459  google.protobuf.Timestamp expiration_time = 3;
460
461  /*
462   * Application-defined metadata.
463   * 
464   * There is no inherent or required relationship between this
465   * and the app_metadata fields in the FlightInfo or resulting
466   * FlightData messages. Since this metadata is application-defined,
467   * a given application could define there to be a relationship,
468   * but there is none required by the spec.
469   */
470  bytes app_metadata = 4;
471}
472
473/*
474 * A location where a Flight service will accept retrieval of a particular
475 * stream given a ticket.
476 */
477message Location {
478  string uri = 1;
479}
480
481/*
482 * An opaque identifier that the service can use to retrieve a particular
483 * portion of a stream.
484 *
485 * Tickets are meant to be single use. It is an error/application-defined
486 * behavior to reuse a ticket.
487 */
488message Ticket {
489  bytes ticket = 1;
490}
491
492/*
493 * A batch of Arrow data as part of a stream of batches.
494 */
495message FlightData {
496
497  /*
498   * The descriptor of the data. This is only relevant when a client is
499   * starting a new DoPut stream.
500   */
501  FlightDescriptor flight_descriptor = 1;
502
503  /*
504   * Header for message data as described in Message.fbs::Message.
505   */
506  bytes data_header = 2;
507
508  /*
509   * Application-defined metadata.
510   */
511  bytes app_metadata = 3;
512
513  /*
514   * The actual batch of Arrow data. Preferably handled with minimal-copies
515   * coming last in the definition to help with sidecar patterns (it is
516   * expected that some implementations will fetch this field off the wire
517   * with specialized code to avoid extra memory copies).
518   */
519  bytes data_body = 1000;
520}
521
522/**
523 * The response message associated with the submission of a DoPut.
524 */
525message PutResult {
526  bytes app_metadata = 1;
527}
528
529/*
530 * EXPERIMENTAL: Union of possible value types for a Session Option to be set to.
531 *
532 * By convention, an attempt to set a valueless SessionOptionValue should
533 * attempt to unset or clear the named option value on the server.
534 */
535message SessionOptionValue {
536  message StringListValue {
537    repeated string values = 1;
538  }
539
540  oneof option_value {
541    string string_value = 1;
542    bool bool_value = 2;
543    sfixed64 int64_value = 3;
544    double double_value = 4;
545    StringListValue string_list_value = 5;
546  }
547}
548
549/*
550 * EXPERIMENTAL: A request to set session options for an existing or new (implicit)
551 * server session.
552 *
553 * Sessions are persisted and referenced via a transport-level state management, typically
554 * RFC 6265 HTTP cookies when using an HTTP transport.  The suggested cookie name or state
555 * context key is 'arrow_flight_session_id', although implementations may freely choose their
556 * own name.
557 *
558 * Session creation (if one does not already exist) is implied by this RPC request, however
559 * server implementations may choose to initiate a session that also contains client-provided
560 * session options at any other time, e.g. on authentication, or when any other call is made
561 * and the server wishes to use a session to persist any state (or lack thereof).
562 */
563message SetSessionOptionsRequest {
564  map<string, SessionOptionValue> session_options = 1;
565}
566
567/*
568 * EXPERIMENTAL: The results (individually) of setting a set of session options.
569 *
570 * Option names should only be present in the response if they were not successfully
571 * set on the server; that is, a response without an Error for a name provided in the
572 * SetSessionOptionsRequest implies that the named option value was set successfully.
573 */
574message SetSessionOptionsResult {
575  enum ErrorValue {
576    // Protobuf deserialization fallback value: The status is unknown or unrecognized.
577    // Servers should avoid using this value. The request may be retried by the client.
578    UNSPECIFIED = 0;
579    // The given session option name is invalid.
580    INVALID_NAME = 1;
581    // The session option value or type is invalid.
582    INVALID_VALUE = 2;
583    // The session option cannot be set.
584    ERROR = 3;
585  }
586
587  message Error {
588    ErrorValue value = 1;
589  }
590  
591  map<string, Error> errors = 1;
592}
593
594/*
595 * EXPERIMENTAL: A request to access the session options for the current server session.
596 *
597 * The existing session is referenced via a cookie header or similar (see
598 * SetSessionOptionsRequest above); it is an error to make this request with a missing,
599 * invalid, or expired session cookie header or other implementation-defined session
600 * reference token.
601 */
602message GetSessionOptionsRequest {
603}
604
605/*
606 * EXPERIMENTAL: The result containing the current server session options.
607 */
608message GetSessionOptionsResult {
609    map<string, SessionOptionValue> session_options = 1;
610}
611
612/*
613 * Request message for the "Close Session" action.
614 *
615 * The exiting session is referenced via a cookie header.
616 */
617message CloseSessionRequest {
618}
619
620/*
621 * The result of closing a session.
622 */
623message CloseSessionResult {
624  enum Status {
625    // Protobuf deserialization fallback value: The session close status is unknown or
626    // not recognized. Servers should avoid using this value (send a NOT_FOUND error if
627    // the requested session is not known or expired). Clients can retry the request.
628    UNSPECIFIED = 0;
629    // The session close request is complete. Subsequent requests with
630    // the same session produce a NOT_FOUND error.
631    CLOSED = 1;
632    // The session close request is in progress. The client may retry
633    // the close request.
634    CLOSING = 2;
635    // The session is not closeable. The client should not retry the
636    // close request.
637    NOT_CLOSEABLE = 3;
638  }
639
640  Status status = 1;
641}