Arrow Flight SQL implementation reference
This page describes how the Arrow Flight and Flight SQL wire is built: the tonic listener, the Flight handshake and bearer tokens, every Flight RPC and Flight SQL command, type mapping in both directions, errors, transactions, limits and tests. For the port, the proof scores and how to connect, see the operator page Arrow Flight SQL. Authentication policy across all wires is in Security.
Code lives in src/protocol/arrow/:
| File | Role |
|---|---|
mod.rs |
ArrowFlightHandler: listener and server start-up. |
flight_grpc.rs |
SynergyFlightService: the Flight service (FlightService trait from arrow-flight), auth, plain Flight RPCs, type conversion. |
flight_sql.rs |
Flight SQL commands carried inside the Flight RPCs. |
service.rs, ipc.rs, types.rs
|
The earlier bespoke Flight-like service. Not the transport; see Not wired. |
Crates: arrow 53 and arrow-flight 53 with the flight-sql-experimental feature, served by tonic. (source: Cargo.toml; src/protocol/arrow/mod.rs)
Build feature and default state
The Cargo feature arrow-flight is empty (arrow-flight = []) and no code is gated on it, so the wire is compiled into every build. (source: Cargo.toml, [features]; no cfg(feature = "arrow-flight") under src/)
The default port is 8815 (arrow_flight_port in ServerConfig::default), so a server started with no config file runs this wire. A config file that omits the key turns it off: synergydb.toml and docker/synergydb.allwires.toml set 8815, and docker/synergydb.toml (the Docker image default) does not. (source: src/config.rs, ServerConfig::default; synergydb.toml; docker/synergydb.toml; docker/synergydb.allwires.toml)
Listener and transport
-
ArrowFlightHandler::startservesFlightServiceServer::new(SynergyFlightService)with decode and encode limits of 1 GiB (1 << 30). Without a storage engine it logs a warning and does not start. (source:src/protocol/arrow/mod.rs,ArrowFlightHandler::start) - With a
[tls]section it usestls::grpc_incoming(ALPNh2, TLS 1.3 and 1.2, first-byte detection), sogrpc+tls://andgrpc://share the port. Plaintext is allowed only whenrequire_tlsis off or the peer is loopback. (source:src/protocol/tls.rs,grpc_incoming,TlsListener::accept_auto) Not verified: no test covers Flight over TLS. -
ArrowFlightHandler::with_storagealso constructs the legacyFlightService::with_storage, which runsCREATE TABLE IF NOT EXISTS _flight_datasets (...)at start-up. Every server that starts this wire therefore has a_flight_datasetstable. (source:src/protocol/arrow/mod.rs,with_storage;src/protocol/arrow/service.rs,FlightService::with_storage)
Authentication
| Step | Behaviour |
|---|---|
Handshake |
Requires authorization: Basic base64(user:pass), checked with verify_credential. Issues a random 32-byte hex token valid for 12 hours (TOKEN_TTL) and returns it in the response header authorization: Bearer <token>. |
| Every other RPC |
authorize accepts Bearer <token> (expired tokens are removed when looked up) or Basic credentials directly. |
| Errors | UNAUTHENTICATED: "invalid or expired bearer token", "invalid credentials", "authentication required: Handshake with Basic credentials, then send the bearer token". |
(source: src/protocol/arrow/flight_grpc.rs, handshake, authorize, issue_token, bearer_user)
- The check is
verify_credential(catalog password and failed-login delay), notverify_wire_credential, sosynergy_wire_flightmembership is not required. (source:src/protocol/arrow/flight_grpc.rs,authorize;src/auth/wire_auth.rs) -
SYNERGYDB_DEV_INSECURE_AUTHis read once when the service is constructed. (source:src/protocol/arrow/flight_grpc.rs,SynergyFlightService::new) - The token map has no size limit, and expired tokens are removed only when a client presents them. (source:
src/protocol/arrow/flight_grpc.rs,issue_token,bearer_user) -
Not verified: no Rust test drives
Handshakeorauthorizeon the wired service.
Database selection
resolve_database uses the database header; otherwise a database named after the user if one exists; otherwise the default database. (source: src/protocol/arrow/flight_grpc.rs, resolve_database)
Plain Flight RPCs
These handle requests that are not Flight SQL commands (source: src/protocol/arrow/flight_grpc.rs):
| RPC | Behaviour |
|---|---|
ListFlights |
One FlightInfo per public table; names starting with _ are skipped. |
GetFlightInfo |
A CMD descriptor holds raw SQL. A PATH descriptor is [table] or [database, table]; an unknown path or invalid identifier gets NOT_FOUND. The query runs to get the schema and row count. The ticket is db:<database>\n<sql> or plain SQL. |
GetSchema |
Schema of the descriptor's query. |
DoGet |
Decodes the ticket, runs the SQL again and streams it with FlightDataEncoderBuilder in batches of 65,536 rows. |
DoPut |
With a PATH descriptor: CREATE TABLE IF NOT EXISTS from the Arrow schema, then INSERT statements of 500 rows with literal values (insert_batch, sql_literal). |
DoAction |
Flight SQL actions only (below); any other action gets UNIMPLEMENTED. |
ListActions |
The Flight SQL action types from sql_action_types. |
DoExchange, PollFlightInfo
|
UNIMPLEMENTED. |
A plain query error is INVALID_ARGUMENT "query failed: …". (source: src/protocol/arrow/flight_grpc.rs, query_batches)
Flight SQL commands
A Flight SQL command is a protobuf Any whose type URL starts with type.googleapis.com/arrow.flight.protocol.sql.; decode_sql_command recognises it. Unit test: sql_commands_are_recognised. (source: src/protocol/arrow/flight_sql.rs, decode_sql_command)
Through GetFlightInfo and DoGet
| Command | Behaviour |
|---|---|
CommandStatementQuery, CommandPreparedStatementQuery
|
Runs the query, keeps the batches for 10 minutes (RESULT_TTL; expired entries are removed when a new result is stored) and returns a TicketStatementQuery handle. DoGet returns the result once; a second fetch gets "unknown or already fetched ticket". |
CommandStatementSubstraitPlan |
UNIMPLEMENTED. |
CommandGetSqlInfo |
Static info: server name SynergyDB, Arrow version 53.4.1, transactions supported, query cancel not supported, bulk ingestion supported, catalog term "database", maximum column name length 63. |
CommandGetXdbcTypeInfo |
bigint, boolean, bytea, char, date, double precision, integer, numeric, real, smallint, text, time, timestamp, timestamptz, varchar. |
CommandGetCatalogs |
Databases visible to the user. |
CommandGetDbSchemas |
Schemas. |
CommandGetTables |
Tables, optionally with Arrow schemas. |
CommandGetTableTypes |
TABLE, VIEW. |
CommandGetPrimaryKeys |
Primary key columns. |
CommandGetImportedKeys, CommandGetExportedKeys, CommandGetCrossReference
|
Foreign keys with update and delete rule codes. |
(source: src/protocol/arrow/flight_sql.rs, sql_get_flight_info, sql_do_get, stash, metadata_batch) Unit test: static_metadata_builds.
Through DoPut
| Command | Behaviour |
|---|---|
CommandStatementUpdate |
Runs DML or DDL; returns the affected row count. |
CommandPreparedStatementQuery |
Binds parameter values to the prepared statement. |
CommandPreparedStatementUpdate |
Runs once per parameter row. Several rows outside a transaction run inside BEGIN/COMMIT. |
CommandStatementIngest |
Bulk load with create, append or replace (TableExistsOption, TableNotExistOption). Runs in its own BEGIN/COMMIT unless inside a Flight SQL transaction. |
(source: src/protocol/arrow/flight_sql.rs, sql_do_put, ingest)
Through DoAction
| Action | Behaviour |
|---|---|
CreatePreparedStatement |
? placeholders become $1..$n (number_placeholders). For a read-only query with no parameters the dataset schema is computed up front. Parameter types are inferred and returned as Arrow types (param_arrow_type). |
ClosePreparedStatement |
Drops the handle. |
BeginTransaction |
Opens a transaction and returns its handle. |
EndTransaction |
COMMIT or ROLLBACK; drops that transaction's prepared statements. |
CancelQuery |
Always returns result 3 (not cancellable). |
CancelFlightInfo |
Always returns status 3 (not cancellable). |
(source: src/protocol/arrow/flight_sql.rs, sql_do_action, number_placeholders) Unit tests: placeholders, parameter_types_declared_for_jdbc.
A DML statement sent as a query returns one row with an Int64 column Count. (source: src/protocol/arrow/flight_sql.rs, query_typed)
Flight SQL work runs through off_async_worker, which uses block_in_place on a multi-thread runtime. The plain Flight path does not. (source: src/protocol/arrow/flight_sql.rs, off_async_worker)
Transactions
- Transactions exist only through the
BeginTransactionandEndTransactionactions; outside them each statement commits on its own. (source:src/protocol/arrow/flight_sql.rs,sql_do_action) - Transaction and prepared-statement handles are looked up by handle alone. The code keeps the opening user and database but does not compare them with the caller (
let _ = (&t.database, &t.user);), so any authenticated client holding a handle can use it. Prepared statements run as the user who created them. (source:src/protocol/arrow/flight_sql.rs,txn,sql_do_actionEndTransaction,run_prepared_query) - There is no idle timeout for Flight SQL transactions. (source:
src/protocol/arrow/flight_sql.rs)
Type mapping
Engine results to Arrow
to_arrow_column maps by PostgreSQL type OID (source: src/protocol/arrow/flight_grpc.rs, to_arrow_column):
| OID | Engine type | Arrow type |
|---|---|---|
| 16 | bool | Boolean |
| 21 | int2 | Int16 |
| 23 | int4 | Int32 |
| 20 | int8 | Int64 |
| 700 | float4 | Float32 |
| 701 | float8 | Float64 |
| 1700 | numeric | Decimal128(p, s) from the declared type; otherwise precision 38 and the largest scale in the data. Values that do not fit fall back to Utf8. |
| 1082 | date | Date32 |
| 1114 | timestamp | Timestamp(microsecond) |
| 1184 | timestamptz | Timestamp(microsecond, "UTC") |
| 1083 | time | Time64(microsecond) |
| 17 | bytea | Binary |
| anything else | Utf8 |
A value that cannot be parsed into its Arrow type becomes NULL. Declared types and NOT NULL are recovered only when the query reads a single table (single_source_table). Unit tests: single_table_detection, decimals, timestamps. (source: src/protocol/arrow/flight_grpc.rs)
Arrow to engine (DoPut and ingest)
sql_type chooses the column type for tables created from an Arrow schema (source: src/protocol/arrow/flight_grpc.rs, sql_type):
| Arrow type | SQL type |
|---|---|
| Boolean | boolean |
| Int8, Int16, UInt8 | smallint |
| Int32, UInt16 | integer |
| Int64, UInt32 | bigint |
| UInt64 | numeric(20,0) |
| Float16, Float32 | real |
| Float64 | double precision |
| Decimal128, Decimal256 | numeric(p,s) |
| Date32, Date64 | date |
| Timestamp with time zone | timestamptz |
| Timestamp without time zone | timestamp |
| Time32, Time64 | time |
| Binary, LargeBinary, FixedSizeBinary | bytea |
| anything else | text |
Error mapping
| Source | gRPC status |
|---|---|
| Flight SQL engine error containing "does not exist" or "not found" | NOT_FOUND |
| Flight SQL engine error containing "already exists" | ALREADY_EXISTS |
| other Flight SQL engine errors | INVALID_ARGUMENT |
| plain Flight query error | INVALID_ARGUMENT "query failed: …" |
| unknown PATH descriptor or bad identifier | NOT_FOUND |
| unknown action, Substrait plan, DoExchange, PollFlightInfo | UNIMPLEMENTED |
| auth failures | UNAUTHENTICATED |
(source: src/protocol/arrow/flight_sql.rs, status_from_engine; src/protocol/arrow/flight_grpc.rs)
The mapping uses message text, not SQLSTATE, and no SQLSTATE trailer is sent. (source: src/protocol/arrow/flight_sql.rs, status_from_engine)
Limits and configuration
| Setting | Default | Effect |
|---|---|---|
[server] arrow_flight_port |
8815 | Listener port; omitted in a config file means off. |
| Message size | 1 GiB | Decode and encode limit. |
TOKEN_TTL |
12 h | Bearer token lifetime. |
RESULT_TTL |
10 min | Flight SQL result kept for DoGet. |
| DoGet batch | 65,536 rows |
BATCH_ROWS. |
| DoPut insert batch | 500 rows |
insert_batch. |
SYNERGYDB_DEV_INSECURE_AUTH |
unset | No authentication (test harnesses only). |
(source: src/config.rs; src/protocol/arrow/mod.rs; src/protocol/arrow/flight_grpc.rs; src/protocol/arrow/flight_sql.rs)
Not wired and not implemented
-
Not wired:
service.rs,ipc.rsandtypes.rs(the earlier bespoke protocol). OnlyFlightService::with_storageruns, to create_flight_datasets. (source:src/protocol/arrow/mod.rs,with_storage) -
Not wired: the
arrow-flightCargo feature gates nothing. (source:Cargo.toml) - The module doc comment in
mod.rsstill says the wire is not wire-compatible with Apache Arrow Flight; the code serves the standardarrow-flightservice. (source:src/protocol/arrow/mod.rs, module doc) - Not implemented: Substrait plans,
DoExchange,PollFlightInfo, query cancellation. (source:src/protocol/arrow/flight_grpc.rs;src/protocol/arrow/flight_sql.rs)
Tests and proof
| Where | What |
|---|---|
src/protocol/arrow/flight_grpc.rs |
single_table_detection, decimals, timestamps. |
src/protocol/arrow/flight_sql.rs |
parameter_types_declared_for_jdbc, placeholders, sql_commands_are_recognised, static_metadata_builds. |
tests/protocol_arrow.rs |
Tests the legacy FlightService (handshake, listing, _flight_datasets persistence), not the wired SynergyFlightService. |
docs/proof/2026-11-30/proof-pack-a3232c9/flight-sql-adbc-app.md |
67/68 ADBC app steps against GizmoSQL; the one difference is the cast_and_arith step (integer versus float division). |
(source: the files named)
No Rust test calls the wired service over a socket. The 33/33 JDBC result on the operator page comes from docs/status/2026-11-30-flight-jdbc-and-exists.md, which this page did not re-check.