Documentation
¶
Index ¶
- Constants
- Variables
- type FlightExecutor
- func (e *FlightExecutor) Close() error
- func (e *FlightExecutor) ConnContext(ctx context.Context) (sqlcore.RawConn, error)
- func (e *FlightExecutor) CopyFromStdin(ctx context.Context, copySQL string, r io.Reader) (int64, error)
- func (e *FlightExecutor) Exec(query string, args ...any) (sqlcore.ExecResult, error)
- func (e *FlightExecutor) ExecContext(ctx context.Context, query string, args ...any) (result sqlcore.ExecResult, err error)
- func (e *FlightExecutor) IsDead() bool
- func (e *FlightExecutor) LastProfilingOutput() string
- func (e *FlightExecutor) MarkDead()
- func (e *FlightExecutor) PingContext(ctx context.Context) error
- func (e *FlightExecutor) Query(query string, args ...any) (sqlcore.RowSet, error)
- func (e *FlightExecutor) QueryContext(ctx context.Context, query string, args ...any) (rs sqlcore.RowSet, err error)
- func (e *FlightExecutor) SetControlMetadata(workerID int, cpInstanceID string, ownerEpoch int64)
- func (e *FlightExecutor) SetOwnerEpoch(ownerEpoch int64)
- type FlightRowSet
Constants ¶
const CopyFromStdinChunkSize = 1 << 20 // 1 MiB
CopyFromStdinChunkSize is the byte size of each FlightData frame sent from the control plane to the worker during a COPY upload. Large enough to amortise per-frame overhead, small enough to keep memory bounded if the worker is slow to drain.
const CopyFromStdinDescriptorPath = "duckgres-copy-from-stdin"
CopyFromStdinDescriptorPath is the FlightDescriptor path that marks a DoPut stream as a CSV-spool-and-COPY upload rather than a standard Flight SQL CommandStatementUpdate. The duckdbservice worker matches on this path and routes to its CopyFromStdin handler.
const CopyFromStdinPathPlaceholder = "__DUCKGRES_COPY_PATH__"
CopyFromStdinPathPlaceholder is the substring inside the COPY SQL that the worker replaces with the worker-local spool file path before executing the COPY. The control plane builds the COPY SQL with BuildDuckDBCopyFromSQL using this token as the file path.
const MaxGRPCMessageSize = 1 << 30 // 1GB
MaxGRPCMessageSize is the max gRPC message size for Flight SQL communication. DuckDB query results can easily exceed the default 4MB limit.
Variables ¶
var ErrWorkerDead = errors.New("flight worker is dead")
ErrWorkerDead is returned when the backing worker process has crashed.
Functions ¶
This section is empty.
Types ¶
type FlightExecutor ¶
type FlightExecutor struct {
// contains filtered or unexported fields
}
FlightExecutor implements QueryExecutor backed by an Arrow Flight SQL client. It routes queries to a duckdb-service worker process over a Unix socket.
func NewFlightExecutor ¶
func NewFlightExecutor(addr, bearerToken, sessionToken string) (*FlightExecutor, error)
NewFlightExecutor creates a FlightExecutor connected to the given address. addr should be "unix:///path/to/socket" for Unix sockets or "host:port" for TCP. bearerToken is the authentication token for the duckdb-service. sessionToken is the session identifier for the x-duckgres-session header.
func NewFlightExecutorFromClient ¶
func NewFlightExecutorFromClient(client *flightsql.Client, sessionToken string) *FlightExecutor
NewFlightExecutorFromClient creates a FlightExecutor that shares an existing Flight SQL client. The client is NOT closed when this executor is closed. This avoids creating a new gRPC connection per session.
func (*FlightExecutor) Close ¶
func (e *FlightExecutor) Close() error
func (*FlightExecutor) ConnContext ¶
func (*FlightExecutor) CopyFromStdin ¶
func (e *FlightExecutor) CopyFromStdin(ctx context.Context, copySQL string, r io.Reader) (int64, error)
CopyFromStdin streams CSV bytes from r to a remote worker, then runs copySQL on the worker against a worker-local spool file. copySQL must contain CopyFromStdinPathPlaceholder where the file path should appear. Returns the number of rows the worker reports COPY-affected.
Wire layout:
frame 0: FlightDescriptor{Type=PATH, Path=[CopyFromStdinDescriptorPath], Cmd=copySQL}
frame 1..N: DataBody=<chunk of CSV bytes>
(client closes send)
server: PutResult{AppMetadata=DoPutUpdateResult{RecordCount=N}}
func (*FlightExecutor) Exec ¶
func (e *FlightExecutor) Exec(query string, args ...any) (sqlcore.ExecResult, error)
func (*FlightExecutor) ExecContext ¶
func (e *FlightExecutor) ExecContext(ctx context.Context, query string, args ...any) (result sqlcore.ExecResult, err error)
func (*FlightExecutor) IsDead ¶
func (e *FlightExecutor) IsDead() bool
IsDead reports whether this executor has been marked dead.
func (*FlightExecutor) LastProfilingOutput ¶
func (e *FlightExecutor) LastProfilingOutput() string
func (*FlightExecutor) MarkDead ¶
func (e *FlightExecutor) MarkDead()
MarkDead marks this executor's backing worker as dead. All subsequent RPC calls will return ErrWorkerDead without touching the (possibly closed) gRPC client.
func (*FlightExecutor) PingContext ¶
func (e *FlightExecutor) PingContext(ctx context.Context) error
func (*FlightExecutor) QueryContext ¶
func (*FlightExecutor) SetControlMetadata ¶
func (e *FlightExecutor) SetControlMetadata(workerID int, cpInstanceID string, ownerEpoch int64)
func (*FlightExecutor) SetOwnerEpoch ¶
func (e *FlightExecutor) SetOwnerEpoch(ownerEpoch int64)
type FlightRowSet ¶
type FlightRowSet struct {
// contains filtered or unexported fields
}
FlightRowSet wraps an Arrow Flight RecordBatch reader to implement RowSet.
func (*FlightRowSet) Close ¶
func (r *FlightRowSet) Close() error
func (*FlightRowSet) ColumnTypes ¶
func (r *FlightRowSet) ColumnTypes() ([]sqlcore.ColumnTyper, error)
func (*FlightRowSet) Columns ¶
func (r *FlightRowSet) Columns() ([]string, error)
func (*FlightRowSet) Err ¶
func (r *FlightRowSet) Err() error
func (*FlightRowSet) Next ¶
func (r *FlightRowSet) Next() bool
func (*FlightRowSet) Scan ¶
func (r *FlightRowSet) Scan(dest ...any) error