Delete
The Airport extension allows tables that it manages to have rows deleted. The Arrow Flight server is responsible for performing the deletes to the data if it chooses.
Example
-- 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
);
-- Delete a single row
DELETE FROM example.main.employees where id = 5;
For an Airport managed table to perform a DELETE
operation it must have a rowid
pseudocolumn.
Airport-managed tables lack the transactional guarantees of native DuckDB tables. When using the INSERT
statement, all rows are sent to the Arrow Flight server where they are presumed to be immediately commited to storage. This differs from a standard SQL transation that doesn’t commit data until COMMIT
or ROLLBACK
is issued.
The current philosophy of the Airport extension is to send the rows to the server. If the server fails to commit the rows during the RPC request, it will raise an Arrow Flight exception, causing the DuckDB transaction to abort.
This may change in the future.
Arrow Flight Server Implementation Notes
If the table does has a rowid pseudocolumn the delete can be performed.
A DoExchange
Arrow Flight RPC is made to delete rows. This allows the server to return rows (needed for the RETURNING
clause), the rows may differ from the original input supplied. On the write stream of the DoExchange
call only the rowid pseudocolumn will be sent to the server.
Supplied gRPC Headers for DoExchange
request.
Header Name | Description |
---|---|
airport-operation |
Set to delete to indicate the operation being performed |
return-chunks |
Set to 1 if a RETURNING clause is present; otherwise, 0 |
Final Metadata Message
When the DuckDB client finishes writing to the write stream of the DoExchange
RPC, the server is expected to return a single metadata message on the read stream that is serialized using msgpack
with this structure.
struct AirportDeleteFinalMetadata
{
uint64_t total_deleted;
(total_deleted)
MSGPACK_DEFINE_MAP};
This message informs the client of the total number of rows successfully deleted from the table.