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

trino

package
v1.56.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 6 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.

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) 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) ResolveTable

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

ResolveTable converts a URN to a table identifier. Applies reverse catalog mapping if configured.

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

	// CatalogMapping maps DataHub catalog names to Trino catalog names.
	// This is the reverse of the semantic layer's catalog mapping.
	// For example: {"warehouse": "rdbms"} means DataHub "warehouse" → Trino "rdbms"
	CatalogMapping map[string]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 DataHub
	// search enrichment very 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