Documentation
¶
Overview ¶
Package query provides abstractions for query execution providers.
Index ¶
- type Column
- type ExecutionContext
- type Executor
- type NoopProvider
- func (n *NoopProvider) Close() error
- func (n *NoopProvider) GetExecutionContext(_ context.Context, _ []string) (*ExecutionContext, error)
- func (n *NoopProvider) GetQueryExamples(_ context.Context, _ string) ([]QueryExample, error)
- func (n *NoopProvider) GetTableAvailability(_ context.Context, _ string) (*TableAvailability, error)
- func (n *NoopProvider) GetTableSchema(_ context.Context, _ TableIdentifier) (*TableSchema, error)
- func (n *NoopProvider) Name() string
- func (n *NoopProvider) ResolveTable(_ context.Context, _ string) (*TableIdentifier, error)
- type Provider
- type QueryExample
- type QueryResult
- type TableAvailability
- type TableIdentifier
- type TableInfo
- type TableSchema
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 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) (*QueryResult, 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) GetExecutionContext ¶
func (n *NoopProvider) GetExecutionContext(_ context.Context, _ []string) (*ExecutionContext, error)
GetExecutionContext returns empty context.
func (*NoopProvider) GetQueryExamples ¶
func (n *NoopProvider) GetQueryExamples(_ context.Context, _ string) ([]QueryExample, error)
GetQueryExamples returns empty examples.
func (*NoopProvider) GetTableAvailability ¶
func (n *NoopProvider) GetTableAvailability(_ context.Context, _ string) (*TableAvailability, error)
GetTableAvailability returns unavailable.
func (*NoopProvider) GetTableSchema ¶
func (n *NoopProvider) GetTableSchema(_ context.Context, _ TableIdentifier) (*TableSchema, error)
GetTableSchema returns empty schema.
func (*NoopProvider) ResolveTable ¶
func (n *NoopProvider) ResolveTable(_ context.Context, _ string) (*TableIdentifier, error)
ResolveTable returns nil.
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) ([]QueryExample, 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 QueryExample ¶
QueryExample provides a sample query for a table.
type QueryResult ¶
type QueryResult struct {
Columns []string `json:"columns"`
Rows [][]interface{} `json:"rows"`
Count int `json:"count"`
}
QueryResult 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.