Skip to content

Feature: ATTACH passthrough mode — forward SQL instead of decomposing into TVF calls #48

Description

@asubbarao

Use case

When using Airport to attach a remote DuckDB instance, the current behavior decomposes function calls into TVF descriptors with positional parameters. This works for custom server-defined functions, but breaks for DuckDB-native extension functions like read_csv, read_text, lsr, etc. that:

  1. Have 40+ parameters with named parameter syntax (auto_detect:=true)
  2. Depend on extensions loaded on the remote side (shellfs, hostfs, etc.)
  3. Have dynamic output schemas that depend on the input

The server IS DuckDB — it can execute any SQL natively. airport_take_flight already sends raw SQL and works perfectly. But ATTACH + USE goes through TVF decomposition, which loses named parameters and requires the server to pre-register every function signature.

Proposal

Add an optional mode parameter to ATTACH:

ATTACH 'grpc://remote:8815' AS remote (TYPE airport, mode passthrough);
USE remote;
-- This SQL is forwarded as-is to the remote DuckDB, not decomposed into TVF calls
SELECT * FROM read_csv('cmd |', auto_detect:=true, header:=false);

In passthrough mode, when the attached catalog receives a query it can't resolve locally (or all queries), it forwards the entire SQL string as a CMD descriptor to the remote — the same path airport_take_flight uses.

The default TVF decomposition behavior stays unchanged for servers that define custom functions. Passthrough mode is for when the remote is a full DuckDB instance and you want ATTACH to be syntactic sugar for airport_take_flight.

Context

Does this make sense as an approach? I don't want to change the default TVF decomposition behavior — just add an optional mode for the remote-DuckDB use case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions