Documentation
¶
Index ¶
- func AppendValue(builder array.Builder, val interface{})
- func BearerTokenStreamInterceptor(expectedToken string) grpc.StreamServerInterceptor
- func BearerTokenUnaryInterceptor(expectedToken string) grpc.UnaryServerInterceptor
- func DuckDBTypeToArrow(dbType string) arrow.DataType
- func GetQuerySchema(ctx context.Context, db contextQueryer, query string, tx contextQueryer) (*arrow.Schema, error)
- func ParseListenAddr(addr string) (network, listenAddr string, err error)
- func QualifyTableName(catalog, schema sql.NullString, table string) string
- func QuoteIdent(ident string) string
- func RowsToRecord(alloc memory.Allocator, rows *sql.Rows, schema *arrow.Schema, batchSize int) (arrow.RecordBatch, error)
- func Run(cfg ServiceConfig)
- type DuckDBService
- type FlightSQLHandler
- func (h *FlightSQLHandler) BeginTransaction(ctx context.Context, req flightsql.ActionBeginTransactionRequest) ([]byte, error)
- func (h *FlightSQLHandler) ClosePreparedStatement(ctx context.Context, req flightsql.ActionClosePreparedStatementRequest) error
- func (h *FlightSQLHandler) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (flightsql.ActionCreatePreparedStatementResult, error)
- func (h *FlightSQLHandler) DoGetDBSchemas(ctx context.Context, cmd flightsql.GetDBSchemas) (*arrow.Schema, <-chan flight.StreamChunk, error)
- func (h *FlightSQLHandler) DoGetPreparedStatement(ctx context.Context, cmd flightsql.PreparedStatementQuery) (*arrow.Schema, <-chan flight.StreamChunk, error)
- func (h *FlightSQLHandler) DoGetStatement(ctx context.Context, ticket flightsql.StatementQueryTicket) (*arrow.Schema, <-chan flight.StreamChunk, error)
- func (h *FlightSQLHandler) DoGetTables(ctx context.Context, cmd flightsql.GetTables) (*arrow.Schema, <-chan flight.StreamChunk, error)
- func (h *FlightSQLHandler) DoPutCommandStatementUpdate(ctx context.Context, cmd flightsql.StatementUpdate) (int64, error)
- func (h *FlightSQLHandler) EndTransaction(ctx context.Context, req flightsql.ActionEndTransactionRequest) error
- func (h *FlightSQLHandler) GetFlightInfoPreparedStatement(ctx context.Context, cmd flightsql.PreparedStatementQuery, ...) (*flight.FlightInfo, error)
- func (h *FlightSQLHandler) GetFlightInfoSchemas(ctx context.Context, cmd flightsql.GetDBSchemas, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
- func (h *FlightSQLHandler) GetFlightInfoStatement(ctx context.Context, cmd flightsql.StatementQuery, ...) (*flight.FlightInfo, error)
- func (h *FlightSQLHandler) GetFlightInfoTables(ctx context.Context, cmd flightsql.GetTables, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
- type QueryHandle
- type ServiceConfig
- type Session
- type SessionPool
- func (p *SessionPool) ActiveSessions() int
- func (p *SessionPool) CloseAll()
- func (p *SessionPool) CreateSession(username, memoryLimit string, threads int) (*Session, error)
- func (p *SessionPool) DestroySession(token string) error
- func (p *SessionPool) GetSession(token string) (*Session, bool)
- func (p *SessionPool) Warmup() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendValue ¶
AppendValue appends a value to an Arrow array builder with type coercion.
func BearerTokenStreamInterceptor ¶
func BearerTokenStreamInterceptor(expectedToken string) grpc.StreamServerInterceptor
BearerTokenStreamInterceptor returns a gRPC stream interceptor that validates the bearer token from the "authorization" metadata header. If expectedToken is empty, no authentication is enforced.
func BearerTokenUnaryInterceptor ¶
func BearerTokenUnaryInterceptor(expectedToken string) grpc.UnaryServerInterceptor
BearerTokenUnaryInterceptor returns a gRPC unary interceptor that validates the bearer token from the "authorization" metadata header. If expectedToken is empty, no authentication is enforced.
func DuckDBTypeToArrow ¶
DuckDBTypeToArrow maps a DuckDB type name to an Arrow DataType.
func GetQuerySchema ¶
func GetQuerySchema(ctx context.Context, db contextQueryer, query string, tx contextQueryer) (*arrow.Schema, error)
GetQuerySchema executes a query with LIMIT 0 to discover the result schema.
func ParseListenAddr ¶
ParseListenAddr parses ListenAddr into a network and address for net.Listen. Supports "unix:///path/to/sock" and TCP addresses like ":8816" or "host:port".
func QualifyTableName ¶
func QualifyTableName(catalog, schema sql.NullString, table string) string
QualifyTableName builds a qualified table name from nullable catalog/schema and table name.
func QuoteIdent ¶
QuoteIdent quotes a SQL identifier to prevent injection.
Types ¶
type DuckDBService ¶
type DuckDBService struct {
// contains filtered or unexported fields
}
DuckDBService is a standalone Arrow Flight SQL service backed by DuckDB.
func NewDuckDBService ¶
func NewDuckDBService(cfg ServiceConfig) *DuckDBService
NewDuckDBService creates a new DuckDB service with the given config.
func (*DuckDBService) Serve ¶
func (svc *DuckDBService) Serve(listener net.Listener) error
Serve starts serving on the given listener.
func (*DuckDBService) Shutdown ¶
func (svc *DuckDBService) Shutdown()
Shutdown gracefully stops the service.
type FlightSQLHandler ¶
type FlightSQLHandler struct {
flightsql.BaseServer
// contains filtered or unexported fields
}
FlightSQLHandler implements Arrow Flight SQL for multiple sessions. Sessions are identified by the "x-duckgres-session" gRPC metadata header.
func NewFlightSQLHandler ¶
func NewFlightSQLHandler(pool *SessionPool) *FlightSQLHandler
NewFlightSQLHandler creates a new multi-session Flight SQL handler.
func (*FlightSQLHandler) BeginTransaction ¶
func (h *FlightSQLHandler) BeginTransaction(ctx context.Context, req flightsql.ActionBeginTransactionRequest) ([]byte, error)
func (*FlightSQLHandler) ClosePreparedStatement ¶
func (h *FlightSQLHandler) ClosePreparedStatement(ctx context.Context, req flightsql.ActionClosePreparedStatementRequest) error
func (*FlightSQLHandler) CreatePreparedStatement ¶
func (h *FlightSQLHandler) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (flightsql.ActionCreatePreparedStatementResult, error)
func (*FlightSQLHandler) DoGetDBSchemas ¶
func (h *FlightSQLHandler) DoGetDBSchemas(ctx context.Context, cmd flightsql.GetDBSchemas) (*arrow.Schema, <-chan flight.StreamChunk, error)
func (*FlightSQLHandler) DoGetPreparedStatement ¶
func (h *FlightSQLHandler) DoGetPreparedStatement(ctx context.Context, cmd flightsql.PreparedStatementQuery) (*arrow.Schema, <-chan flight.StreamChunk, error)
func (*FlightSQLHandler) DoGetStatement ¶
func (h *FlightSQLHandler) DoGetStatement(ctx context.Context, ticket flightsql.StatementQueryTicket) (*arrow.Schema, <-chan flight.StreamChunk, error)
func (*FlightSQLHandler) DoGetTables ¶
func (h *FlightSQLHandler) DoGetTables(ctx context.Context, cmd flightsql.GetTables) (*arrow.Schema, <-chan flight.StreamChunk, error)
func (*FlightSQLHandler) DoPutCommandStatementUpdate ¶
func (h *FlightSQLHandler) DoPutCommandStatementUpdate(ctx context.Context, cmd flightsql.StatementUpdate) (int64, error)
func (*FlightSQLHandler) EndTransaction ¶
func (h *FlightSQLHandler) EndTransaction(ctx context.Context, req flightsql.ActionEndTransactionRequest) error
func (*FlightSQLHandler) GetFlightInfoPreparedStatement ¶
func (h *FlightSQLHandler) GetFlightInfoPreparedStatement(ctx context.Context, cmd flightsql.PreparedStatementQuery, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
func (*FlightSQLHandler) GetFlightInfoSchemas ¶
func (h *FlightSQLHandler) GetFlightInfoSchemas(ctx context.Context, cmd flightsql.GetDBSchemas, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
func (*FlightSQLHandler) GetFlightInfoStatement ¶
func (h *FlightSQLHandler) GetFlightInfoStatement(ctx context.Context, cmd flightsql.StatementQuery, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
func (*FlightSQLHandler) GetFlightInfoTables ¶
func (h *FlightSQLHandler) GetFlightInfoTables(ctx context.Context, cmd flightsql.GetTables, desc *flight.FlightDescriptor) (*flight.FlightInfo, error)
type QueryHandle ¶
QueryHandle stores a prepared or ad-hoc query for later execution.
type ServiceConfig ¶
type ServiceConfig struct {
// ListenAddr is the address to listen on.
// Formats: "unix:///var/run/duckgres/duckdb.sock" or ":8816" or "0.0.0.0:8816"
ListenAddr string
// ListenFD is an inherited file descriptor for a pre-bound listener.
// When > 0, the service uses this FD instead of creating a new socket.
// This is used by the control plane to pass a pre-bound Unix socket to
// worker processes, avoiding EROFS errors under ProtectSystem=strict.
ListenFD int
// ServerConfig is reused for CreateDBConnection (data_dir, extensions, DuckLake).
ServerConfig server.Config
// BearerToken is the authentication token for gRPC requests.
// If empty, no authentication is required.
BearerToken string
// MaxSessions limits the number of concurrent sessions. 0 means unlimited.
MaxSessions int
}
ServiceConfig configures the standalone DuckDB Arrow Flight SQL service.
type Session ¶
type Session struct {
ID string
DB *sql.DB
Conn *sql.Conn // Dedicated connection for this session
Username string
CreatedAt time.Time
// contains filtered or unexported fields
}
Session represents a single DuckDB session.
type SessionPool ¶
type SessionPool struct {
// contains filtered or unexported fields
}
SessionPool manages multiple DuckDB sessions keyed by session token.
func (*SessionPool) ActiveSessions ¶
func (p *SessionPool) ActiveSessions() int
ActiveSessions returns the number of active sessions.
func (*SessionPool) CreateSession ¶
func (p *SessionPool) CreateSession(username, memoryLimit string, threads int) (*Session, error)
CreateSession creates a new DuckDB session for the given username.
func (*SessionPool) DestroySession ¶
func (p *SessionPool) DestroySession(token string) error
DestroySession closes and removes a session.
func (*SessionPool) GetSession ¶
func (p *SessionPool) GetSession(token string) (*Session, bool)
GetSession returns a session by token.
func (*SessionPool) Warmup ¶
func (p *SessionPool) Warmup() error
Warmup performs one-time initialization of the shared DuckDB instance. This loads extensions and attaches catalogs so that subsequent session creations are nearly instantaneous.