Help us shape the future of Go! Take the 2026 Go Developer Survey

trino

package
v1.149.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package trino provides a Trino implementation of the query provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements query.Provider using Trino.

func New

func New(cfg Config) (*Adapter, error)

New creates a new Trino adapter with a real client.

func NewWithClient

func NewWithClient(cfg Config, client Client) (*Adapter, error)

NewWithClient creates a new Trino adapter with a provided client (for testing).

func (*Adapter) Close

func (a *Adapter) Close() error

Close releases resources.

func (*Adapter) GetExecutionContext

func (a *Adapter) GetExecutionContext(ctx context.Context, urns []string) (*query.ExecutionContext, error)

GetExecutionContext returns context for querying multiple tables.

func (*Adapter) GetQueryExamples

func (a *Adapter) GetQueryExamples(ctx context.Context, urn string) ([]query.Example, error)

GetQueryExamples returns sample queries for a table.

func (*Adapter) GetTableAvailability

func (a *Adapter) GetTableAvailability(ctx context.Context, urn string) (*query.TableAvailability, error)

GetTableAvailability checks if a table is queryable, estimating its row count when the adapter is configured to.

func (*Adapter) GetTableSchema

func (a *Adapter) GetTableSchema(ctx context.Context, table query.TableIdentifier) (*query.TableSchema, error)

GetTableSchema returns the schema of a table.

func (*Adapter) ListCatalogs added in v1.102.0

func (a *Adapter) ListCatalogs(ctx context.Context) ([]string, error)

ListCatalogs returns the Trino catalog names. It implements query.CatalogBrowser so argument autocompletion can enumerate the namespace.

func (*Adapter) ListSchemas added in v1.102.0

func (a *Adapter) ListSchemas(ctx context.Context, catalog string) ([]string, error)

ListSchemas returns the schema names in a Trino catalog.

func (*Adapter) ListTables added in v1.102.0

func (a *Adapter) ListTables(ctx context.Context, catalog, schema string) ([]string, error)

ListTables returns the table names in a Trino catalog schema. The upstream client returns rich TableInfo records; only the bare name is needed for autocompletion.

func (*Adapter) Name

func (*Adapter) Name() string

Name returns the provider name.

func (*Adapter) Ping

func (a *Adapter) Ping(ctx context.Context) error

Ping tests the connection to Trino.

func (*Adapter) ResolveLocation added in v1.120.0

func (a *Adapter) ResolveLocation(ctx context.Context, urn string) (*query.TableAvailability, error)

ResolveLocation checks if a table is queryable without ever estimating its row count, implementing query.LocationResolver for callers that need only the table and connection behind a URN (an advisory marker on a request path) and must not pay for a COUNT(*) to get them.

func (*Adapter) ResolveTable

func (*Adapter) ResolveTable(_ context.Context, urn string) (*query.TableIdentifier, error)

ResolveTable converts a platform catalog dataset reference (#1919) to the table it names: the reference carries its connection and path outright. Anything else is refused, naming the form that is read.

func (*Adapter) SetMetrics added in v1.70.0

func (a *Adapter) SetMetrics(m *observability.Metrics)

SetMetrics wraps the adapter's client in an instrumenting decorator that records Trino metrics AND opens a per-call span. The platform installs it only when metrics OR tracing is enabled; the decorator's metric record is nil-safe and its span is a no-op outside an active trace, so whichever subsystem is off costs effectively nothing.

type Client

type Client interface {
	Query(ctx context.Context, sql string, opts trinoclient.QueryOptions) (*trinoclient.QueryResult, error)
	ListCatalogs(ctx context.Context) ([]string, error)
	ListSchemas(ctx context.Context, catalog string) ([]string, error)
	ListTables(ctx context.Context, catalog, schema string) ([]trinoclient.TableInfo, error)
	DescribeTable(ctx context.Context, catalog, schema, table string) (*trinoclient.TableInfo, error)
	Ping(ctx context.Context) error
	Close() error
}

Client defines the interface for Trino operations. This allows for mocking in tests.

type Config

type Config struct {
	Host           string
	Port           int
	User           string
	Password       string // #nosec G117 -- Trino connection credential from admin config
	Catalog        string
	Schema         string
	SSL            bool
	SSLVerify      bool
	Timeout        time.Duration
	DefaultLimit   int
	MaxLimit       int
	ReadOnly       bool
	ConnectionName string

	// EstimateRowCounts controls whether GetTableAvailability runs
	// SELECT COUNT(*) to estimate row counts. Disabled by default because
	// COUNT(*) can cause full table scans on large tables, making every
	// availability answer slow.
	EstimateRowCounts bool
}

Config holds Trino adapter configuration.

Jump to

Keyboard shortcuts

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