Documentation
¶
Overview ¶
Package engine orchestrates a dfetch query: parse the SQL, resolve each referenced schema to a connector, fetch and load each table into a per-request local SQLite database (pushing down as much of the query as is safe), then resolve the original query against it.
Index ¶
- type Engine
- func (e *Engine) DescribeTable(ctx context.Context, schema, table string) (source.TableSchema, error)
- func (e *Engine) ListTables(ctx context.Context, schema, filter string) ([]string, error)
- func (e *Engine) Run(ctx context.Context, query string) (*Result, error)
- func (e *Engine) RunWithParams(ctx context.Context, query string, params map[string]any) (*Result, error)
- func (e *Engine) SchemaSummaries(ctx context.Context) []SchemaSummary
- type Result
- type SchemaSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine resolves dfetch queries against configured connectors, keyed by the SQL schema they serve (e.g. "github").
func (*Engine) DescribeTable ¶
func (e *Engine) DescribeTable(ctx context.Context, schema, table string) (source.TableSchema, error)
DescribeTable returns the column schema of one table, resolving it on demand for dynamic connectors (SchemaDescriber) and from Tables() otherwise.
func (*Engine) ListTables ¶
ListTables returns the table names served under schema, filtered by a case-insensitive substring. A dynamic connector (TableLister) lists on demand; a static one lists from Tables().
func (*Engine) RunWithParams ¶
func (e *Engine) RunWithParams(ctx context.Context, query string, params map[string]any) (*Result, error)
RunWithParams executes the full pipeline for a SQL query (SQLite syntax), binding params as named SQLite parameters (referenced as :name in the SQL). A nil or empty params map runs the query with no bound parameters.
The params are also handed to the push-down planner: the planner resolves a bind-parameter RHS (e.g. `service_name = :service`) to its value so the filter can be pushed to the connector, while the final query keeps the :name bind for SQLite. Without this, connectors that require a filter value at fetch time (jaeger.spans needs service_name or trace_id, github.pulls needs owner/repo) would never see the value, since a bind is opaque until SQLite executes.
func (*Engine) SchemaSummaries ¶
func (e *Engine) SchemaSummaries(ctx context.Context) []SchemaSummary
SchemaSummaries returns one summary per connector schema (sorted), for the top-level `dfetch tables` view. A dynamic source's count comes from listing its table names; if that fails (e.g. the source is unreachable) the count is -1 rather than failing the whole listing.
type Result ¶
Result holds the columns and rows produced by a resolved query, plus any non-fatal warnings gathered while fetching (e.g. a connector truncated at a cap, so the result may be incomplete).
func (*Result) Project ¶
Project returns a copy of the result narrowed to cols, in the given order. An empty cols list returns the result unchanged (all columns). It errors if a requested column is not present, listing the columns that are available, so a stale saved-query projection fails loudly rather than silently dropping data.
type SchemaSummary ¶
type SchemaSummary struct {
Schema string
TableCount int // number of tables, or -1 when a dynamic source couldn't be listed
Dynamic bool // true when the connector lists/describes tables on demand
}
SchemaSummary is one schema's entry in the top-level `dfetch tables` listing.