query

package
v1.126.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package query provides abstractions for query execution providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogBrowser added in v1.102.0

type CatalogBrowser interface {
	// ListCatalogs returns the catalog names visible to the engine connection.
	ListCatalogs(ctx context.Context) ([]string, error)
	// ListSchemas returns the schema names in a catalog.
	ListSchemas(ctx context.Context, catalog string) ([]string, error)
	// ListTables returns the table names in a catalog schema.
	ListTables(ctx context.Context, catalog, schema string) ([]string, error)
}

CatalogBrowser enumerates the catalog/schema/table namespace of the query engine. It is an optional capability layered on top of Provider (not every provider can browse), consumed by argument autocompletion for the schema:// and availability:// resource templates. The returned names are the raw engine identifiers; callers apply their own persona/connection filtering.

func CatalogBrowserFrom added in v1.102.0

func CatalogBrowserFrom(p Provider) (CatalogBrowser, bool)

CatalogBrowserFrom reports the catalog-browse capability of p, returning the innermost provider that implements it. It unwraps any decorator chain so a wrapped provider still exposes the capability; browse lookups are namespace listings (not per-table context), so reaching the underlying provider directly is correct. ok is false when no provider in the chain can browse.

type Column

type Column struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Nullable bool   `json:"nullable"`
	Comment  string `json:"comment,omitempty"`
}

Column represents a table column.

type Example added in v0.14.0

type Example struct {
	Description string `json:"description"`
	SQL         string `json:"sql"`
}

Example provides a sample query for a table.

type ExecutionContext

type ExecutionContext struct {
	Tables      []TableInfo `json:"tables"`
	Connections []string    `json:"connections"`
}

ExecutionContext provides context for executing queries against multiple tables.

type Executor

type Executor interface {
	// Execute runs a query and returns results.
	Execute(ctx context.Context, sql string, limit int) (*Result, error)

	// Describe returns information about a table.
	Describe(ctx context.Context, table TableIdentifier) (*TableSchema, error)
}

Executor can execute queries against the query engine.

type LocationResolver added in v1.120.0

type LocationResolver interface {
	// ResolveLocation reports whether the entity is queryable and where, with
	// EstimatedRows always nil. Its contract is otherwise GetTableAvailability's:
	// an entity that cannot be resolved comes back Available=false with Error
	// set, not as an error.
	ResolveLocation(ctx context.Context, urn string) (*TableAvailability, error)
}

LocationResolver is the optional capability of a Provider to answer WHERE a catalog entity is queryable without also measuring HOW MUCH is in it.

GetTableAvailability fills EstimatedRows with a COUNT(*) when the provider is configured for it, which is unbounded work against the warehouse. A caller that only needs the table and connection behind a URN — naming the query that would settle a claim, rather than comparing a number against one — asks through this instead, so an advisory answer on a request path never costs a full scan. A provider that does not implement it is asked the ordinary way.

type NoopProvider

type NoopProvider struct{}

NoopProvider is a no-op implementation for testing.

func NewNoopProvider

func NewNoopProvider() *NoopProvider

NewNoopProvider creates a new no-op provider.

func (*NoopProvider) Close

func (*NoopProvider) Close() error

Close does nothing.

func (*NoopProvider) GetExecutionContext

func (*NoopProvider) GetExecutionContext(_ context.Context, _ []string) (*ExecutionContext, error)

GetExecutionContext returns empty context.

func (*NoopProvider) GetQueryExamples

func (*NoopProvider) GetQueryExamples(_ context.Context, _ string) ([]Example, error)

GetQueryExamples returns empty examples.

func (*NoopProvider) GetTableAvailability

func (*NoopProvider) GetTableAvailability(_ context.Context, _ string) (*TableAvailability, error)

GetTableAvailability returns unavailable.

func (*NoopProvider) GetTableSchema

func (*NoopProvider) GetTableSchema(_ context.Context, _ TableIdentifier) (*TableSchema, error)

GetTableSchema returns empty schema.

func (*NoopProvider) Name

func (*NoopProvider) Name() string

Name returns the provider name.

func (*NoopProvider) ResolveTable

func (*NoopProvider) ResolveTable(_ context.Context, _ string) (*TableIdentifier, error)

ResolveTable returns an empty identifier.

type Provider

type Provider interface {
	// Name returns the provider name.
	Name() string

	// ResolveTable converts a URN to a query table identifier.
	ResolveTable(ctx context.Context, urn string) (*TableIdentifier, error)

	// GetTableAvailability checks if a table is queryable.
	GetTableAvailability(ctx context.Context, urn string) (*TableAvailability, error)

	// GetQueryExamples returns sample queries for a table.
	GetQueryExamples(ctx context.Context, urn string) ([]Example, error)

	// GetExecutionContext returns context for querying multiple tables.
	GetExecutionContext(ctx context.Context, urns []string) (*ExecutionContext, error)

	// GetTableSchema returns the schema of a table.
	GetTableSchema(ctx context.Context, table TableIdentifier) (*TableSchema, error)

	// Close releases resources.
	Close() error
}

Provider provides query execution context for metadata entities. Trino implements this. Future engines (Spark, Presto) can too.

type Result added in v0.14.0

type Result struct {
	Columns []string `json:"columns"`
	Rows    [][]any  `json:"rows"`
	Count   int      `json:"count"`
}

Result represents the result of a query.

type TableAvailability

type TableAvailability struct {
	Available     bool   `json:"available"`
	QueryTable    string `json:"query_table,omitempty"`
	Connection    string `json:"connection,omitempty"`
	EstimatedRows *int64 `json:"estimated_rows,omitempty"`
	Error         string `json:"error,omitempty"`
}

TableAvailability indicates if a table is queryable.

type TableIdentifier

type TableIdentifier struct {
	Catalog    string `json:"catalog,omitempty"`
	Schema     string `json:"schema"`
	Table      string `json:"table"`
	Connection string `json:"connection,omitempty"`
}

TableIdentifier uniquely identifies a table in the query engine.

func (TableIdentifier) String

func (t TableIdentifier) String() string

String returns a dot-separated representation.

type TableInfo

type TableInfo struct {
	URN           string `json:"urn"`
	QueryTable    string `json:"query_table"`
	Connection    string `json:"connection"`
	EstimatedRows *int64 `json:"estimated_rows,omitempty"`
}

TableInfo provides information about a queryable table.

type TableSchema

type TableSchema struct {
	Columns    []Column `json:"columns"`
	PrimaryKey []string `json:"primary_key,omitempty"`
}

TableSchema represents the schema of a table.

type Verifiable added in v1.120.0

type Verifiable struct {
	URN        string `json:"urn" example:"urn:li:dataset:(urn:li:dataPlatform:trino,iceberg.retail.orders,PROD)"`
	QueryTable string `json:"query_table" example:"iceberg.retail.orders"`
	Connection string `json:"connection,omitempty" example:"primary"`
}

Verifiable is the queryable identity behind a delivered claim: the table one query would settle the claim against, and the connection that table lives on.

It is the delivery-side projection of TableAvailability, carrying only what a consumer needs to check a claim for itself rather than take it on trust. URN names which of a record's entities resolved, so a claim linked to several entities is unambiguous about the one it can be checked against.

It is only ever produced for an entity a query provider reported as available, so its presence means "this can be checked here", not "this was checked".

Directories

Path Synopsis
Package trino provides a Trino implementation of the query provider.
Package trino provides a Trino implementation of the query provider.

Jump to

Keyboard shortcuts

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