querytext

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package querytext reads the texts a person types for a query into QueryService's typed messages, and writes them back: a filter status=running, a sort -create_time, a group create_time::week, a measure cost=usage.cost_usd::sum. QueryService only reads typed messages; the command line and djinn mcp read their texts here, on the caller's side, a filter typed by the ref it reads, which the collection's schema gives.

Index

Constants

View Source
const (
	FilterHelp = "a filter: ref, an operator, a value, read with the type of the ref. = is equal, text ignoring case, " +
		"and a|b one of; != is none of, an absent value included; > >= < <= bound a number, a time (2026-11-01, in " +
		"this machine's time zone, or RFC 3339) or a duration (90s); *= contains, ^= begins with, ignoring case; " +
		"null is the absent value: status=null, status!=null, status=pending|null. An enum takes its value's name, " +
		"prefix or not: status=running"
	OrderHelp = "a sort: ref ascending, -ref descending; aggregated, a column of the table: -count"
	GroupHelp = "a group: ref, ref::day, ref::week, ref::month, or ref::bins(b1,b2,...) for a number or a " +
		"duration: answer::delay::bins(0s,1m,10m,1h)"
	MeasureHelp = "a measure: count, ref::fn with fn count, sum, avg, min, max, median or p90, or name=ref::fn to " +
		"name its column: running::median"
)

The grammars of the texts, as the help of the command line says them.

Variables

View Source
var ErrInvalid = errors.New("invalid query text")

ErrInvalid wraps the error of a text that does not read.

Functions

func Filter

func Filter(ctx context.Context, s string, c queryv1.Collection, types *Types) (*queryv1.Filter, error)

Filter reads a filter of the collection c, typed by its ref's type.

func FilterText

func FilterText(f *queryv1.Filter) string

FilterText is the text of f; a group of and, or a not of more than one filter, has none: "".

func Group

func Group(ctx context.Context, s string, c queryv1.Collection, types *Types) (*queryv1.GroupBy, error)

Group reads a group of the collection c: ref, ref::day, ref::week, ref::month, or ref::bins(b1,b2,...), whose bounds read as the ref's type, a number or a duration.

func GroupText

func GroupText(g *queryv1.GroupBy) string

GroupText is the text of g.

func Measure

func Measure(s string) (*queryv1.Measure, error)

Measure reads a measure: count, ref::fn, or name=ref::fn (name=count) to name its column.

func MeasureText

func MeasureText(m *queryv1.Measure) string

MeasureText is the text of m.

func Order

func Order(s string) (*queryv1.Order, error)

Order reads a sort: ref ascending, -ref descending.

func OrderText

func OrderText(o *queryv1.Order) string

OrderText is the text of o.

func Time

func Time(s string) (time.Time, error)

Time reads an instant: RFC 3339, or a day alone, which starts at midnight on this machine, as the window shows days.

Types

type Schema

type Schema func(ctx context.Context, c queryv1.Collection) ([]*queryv1.QueryColumn, error)

Schema gives the refs of a collection, as QueryService.Schema does.

type Types

type Types struct {
	// contains filtered or unexported fields
}

Types gives the type of a ref, reading each collection's schema once.

func NewTypes

func NewTypes(schema Schema) *Types

NewTypes reads the types of refs through schema.

func (*Types) Of

Of is the type of ref in the collection c: a field, a ref Djinn computes, or one read across a jump (wish_id->title).

Jump to

Keyboard shortcuts

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