{"modulePath":"github.com/labstack/pitot","version":"v0.0.0-20261123231833-0301fe8e3bdc","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queryrows\n\n## Constants\n\n```go\nconst CompletedTraceLimit = 21\n```\nCompletedTraceLimit is the deepest ranking CompletedTraceQuery answers exactly; the read cache keeps enough spans per partition for this depth.\n\n```go\nconst CompletedTraceQuery = `SELECT namespace,trace_id,max(has_error) AS has_error FROM trace_exemplars\n WHERE start_time\u003e=$1::TIMESTAMP_NS::TIMESTAMPTZ_NS AND start_time\u003c$2::TIMESTAMP_NS::TIMESTAMPTZ_NS\n AND ($3='' OR namespace=$4) AND ($5='' OR service=$6) AND trace_id\u003c\u003e''\n GROUP BY namespace,trace_id\n ORDER BY max([has_error::BIGINT,duration]) DESC,trace_id,namespace LIMIT $7`\n```\nCompletedTraceQuery ranks scoped traces by their best in-window span: an error first, then the longest span, then trace\\_id and namespace. Arguments are start, end, namespace twice, service twice, and a limit of at most CompletedTraceLimit. Results are namespace, trace\\_id, and whether the trace has an in-scope, in-window error span.\n\n## Functions\n\n```go\nfunc ReadWindowColumns(ctx context.Context) ([]string, bool)\n```\n\n```go\nfunc RecordCoverage(ctx context.Context, fresh time.Time)\n```\n\n```go\nfunc WithInventoryWindow(ctx context.Context, window Window) context.Context\n```\nWithInventoryWindow records the logical panel interval before file lookback expansion. It is independent of the raw-file read window and read kind.\n\n```go\nfunc WithReadProfile(ctx context.Context, p *ReadProfile) context.Context\n```\n\n```go\nfunc WithWindow(ctx context.Context, window Window) context.Context\n```\n\n```go\nfunc WithWindowColumns(ctx context.Context, columns []string) context.Context\n```\nWithWindowColumns records the exact columns a trusted SQL panel bounds with the read window, captured at macro expansion where each column is unambiguous. A raw signal is event-time pruned by the window only when one of these columns is that signal's own event-time clock; a window on any other column (or on another relation joined to it) binds every captured file for the signal instead of silently dropping rows. Absent entirely, every raw signal keeps its default clock-based pruning.\n\n## Types\n\n```go\ntype Coverage struct {\n\t// contains filtered or unexported fields\n}\n```\nCoverage carries the oldest incomplete ingest horizon back from snapshot binding to the panel result. Comparisons and auxiliary reads share the value.\n\n```go\nfunc WithCoverage(ctx context.Context) (context.Context, *Coverage)\n```\n\n```go\nfunc (c *Coverage) FreshTo() time.Time\n```\n\n```go\ntype Queryer interface {\n\tQueryContext(ctx context.Context, query string, args ...any) (Rows, error)\n}\n```\n\n```go\ntype ReadKind uint8\n```\nReadKind identifies private aggregate relations used by trusted dashboard SQL.\n\n```go\nconst (\n\tRawRead ReadKind = iota\n\tTraceCandidateRead\n)\n```\n\n```go\ntype ReadProfile struct {\n\tWait, Bind, Execute time.Duration\n\t// Cached batches rank from read_trace_exemplars; tail batches and their\n\t// spans are read raw, filtered when Pruned.\n\tCachedBatches, TailBatches, TailSpans int\n\tPruned                                bool\n}\n```\nReadProfile carries one read's phase times, and for a trace ranking its source's shape, back to the caller's slow-request log. A context holds it for a single QueryContext call.\n\n```go\nfunc ReadProfileFrom(ctx context.Context) *ReadProfile\n```\nReadProfileFrom returns the context's profile, or nil.\n\n```go\ntype ReadTransactioner interface {\n\tWithReadTransaction(context.Context, func(Queryer) error) error\n}\n```\nReadTransactioner runs related reads on one connection and database snapshot.\n\n```go\ntype Rows interface {\n\tClose() error\n\tColumns() ([]string, error)\n\tErr() error\n\tNext() bool\n\tScan(dest ...any) error\n}\n```\nRows is the database row-stream surface used by query consumers. Keeping it as an interface lets storage engines attach resource-lifetime behavior (for example, retaining a Parquet snapshot lock until iteration is complete).\n\n```go\ntype SQLAdapter struct{ DB SQLQueryer }\n```\n\n```go\nfunc (a SQLAdapter) QueryContext(ctx context.Context, query string, args ...any) (Rows, error)\n```\n\n```go\nfunc (a SQLAdapter) WithReadTransaction(ctx context.Context, read func(Queryer) error) error\n```\n\n```go\ntype SQLQueryer interface {\n\tQueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)\n}\n```\nSQLQueryer is implemented by \\*sql.DB and sqlmock's database handle.\n\n```go\ntype Window struct {\n\tStart, End         time.Time\n\tNamespace, Service string\n\tKind               ReadKind\n\t// RetainedInventory is exact retained-service membership, including uncached\n\t// files. It ignores event time only for resource_inventory; raw relations\n\t// still require the caller's explicit event-time predicates.\n\tRetainedInventory bool\n}\n```\nWindow is an explicit internal read scope. Only callers that apply these event-time predicates may use it to exclude immutable Parquet files.\n\n```go\nfunc ReadInventoryWindow(ctx context.Context) (Window, bool)\n```\n\n```go\nfunc ReadWindow(ctx context.Context) (Window, bool)\n```\n\n","path":"github.com/labstack/pitot/internal/queryrows","name":"queryrows","synopsis":"","isRedistributable":true}
