Select
The Airport extension enables DuckDB to query remote data using standard SELECT
statements. It integrates with Arrow Flight to either stream data or return the data’s location. Optionally, the Arrow Flight server may filter results before returning them using the query’s predicates.
Example
You can query Airport-managed tables just like any other DuckDB table:
-- Attach an Airport database
'example' (TYPE AIRPORT, location 'grpc://localhost:50312/');
ATTACH
-- Assume that there is a `main` schema
-- already in the `example` database
CREATE TABLE example.main.employees (
varchar,
name id integer
);
SELECT * FROM example.main.employees;
-- Queries that specify a point in time
-- or version of the table are supported, if
-- the Arrow flight server supports it.
SELECT * FROM example.main.exployees AT (TIMESTAMP => TIMESTAMP '2020-01-01');
SELECT * FROM example.main.employees AT (VERSION => 42);
You can join Airport tables with other tables or use multiple Airport sources in a single query. DuckDB fetches them in parallel, constrained only by available threads. If a table appears multiple times, each use results in a separate request.
Arrow Flight Server Implementation Notes
DuckDB Catalog Integration
To learn how to register an Arrow Flight data a a DuckDB table, refer to Server Catalog Integration.
Time Travel / Point in Time Lookup
When a query includes time travel or point-in-time semantics, the Airport extension issues a flight_info
RPC. This retrieves the FlightInfo
structure representing the table as it existed at that specific moment in time. This ensures that queries reflect the correct schema, even if the table has evolved over time.
Endpoint / Location Lookup
To fetch data from a flight, the Airport extension performs a DoAction
RPC named endpoints
, instead of the standard GetFlightInfo
RPC. This is done because:
- The schema is already known and doesn’t need to be returned.
- Filter predicates can be serialized and sent, allowing the server to filter endpoints.
GetFlightInfo
doesn’t allow additional data beyond theFlightDescriptor
to be passed.