query

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 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 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 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.

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