thrift

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package thrift is the Thrift/HiveServer2 implementation of backend.Backend. It owns the generated TCLIService client, the open-session response, and the execute/poll/close/session RPCs, so that internal/cli_service is imported only here and not by the rest of the driver.

Steps are instrumented via internal/debuglog (gated, ordered, timed, function-tagged) so a failing or slow step is visible across the execute/poll/fetch flow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParamsToSparkForTest

func ParamsToSparkForTest(params []backend.Param) []*cli_service.TSparkParameter

ParamsToSparkForTest exposes the neutral-param -> TSparkParameter mapping so the dbsql parameter tests can assert on the Thrift wire form end-to-end.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is the Thrift implementation of backend.Backend. One Backend backs one conn and is used by a single goroutine at a time (database/sql pool discipline), so it holds no locks.

func New

func New(ctx context.Context, cfg *config.Config, httpClient *http.Client) (*Backend, error)

New builds a Thrift backend from the driver config and the shared HTTP client. The Thrift client is constructed here; the session is not opened until OpenSession. ctx carries the caller's correlation id onto a client-init error.

func NewForTest

func NewForTest(cli cli_service.TCLIService, session *cli_service.TOpenSessionResp, cfg *config.Config) *Backend

NewForTest builds a Thrift Backend from a mock client, a canned session, and a config, bypassing New and OpenSession, so the dbsql connection tests can back a conn with an injected mock client. It populates the cached sessionID from the handle exactly as OpenSession would.

func (*Backend) CloseSession

func (b *Backend) CloseSession(ctx context.Context) error

CloseSession closes the server-side session, returning the raw RPC error. The caller owns the DELETE_SESSION telemetry timing and the error classification.

func (*Backend) Execute

func (b *Backend) Execute(ctx context.Context, req backend.ExecRequest) (backend.Operation, error)

Execute runs the statement to a terminal state and returns a thriftOperation carrying the execute and status responses. Per the backend.Backend contract the returned Operation is non-nil even on error.

func (*Backend) OpenSession

func (b *Backend) OpenSession(ctx context.Context) error

OpenSession opens the server-side Thrift session, wiring the session params and initial namespace (catalog/schema) from the config.

func (*Backend) OperationForTest

func (b *Backend) OperationForTest(exStmtResp *cli_service.TExecuteStatementResp, opStatusResp *cli_service.TGetOperationStatusResp) *thriftOperation

OperationForTest builds an Operation wrapping a canned execute response and status, using this backend for any follow-up RPCs (e.g. the GetResultSetMetadata that IsStaging may issue).

func (*Backend) ServerProtocolVersion

func (b *Backend) ServerProtocolVersion() cli_service.TProtocolVersion

ServerProtocolVersion returns the negotiated Thrift protocol version for the open session, for the connector's connect log. It is Thrift-specific and so is not part of the neutral backend.Backend interface; the connector reads it off the concrete *Backend it constructed. Returns 0 before OpenSession.

func (*Backend) SessionID

func (b *Backend) SessionID() string

SessionID returns the formatted server session id (conn.id's value), computed once in OpenSession. Empty until OpenSession succeeds.

func (*Backend) SessionValid

func (b *Backend) SessionValid() bool

SessionValid backs conn.IsValid: the session is usable while its open-status code is SUCCESS. No I/O — matches today's behavior exactly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL