queryops

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package queryops derives bounded, previewable DTQL operations without running a query or resolving any source. It only transforms DALgo's typed AST and returns a canonical DTQL document for the caller to inspect or submit.

Index

Constants

View Source
const MaxPreviewRows = 500

Variables

View Source
var (
	ErrUnsupported   = errors.New("query derivation is unsupported")
	ErrInvalidColumn = errors.New("query derivation has an invalid or ambiguous column")
)

Functions

func AggregateAlias

func AggregateAlias(function, column string, reserved []string) string

AggregateAlias produces a readable stable identifier, suffixing collisions case-insensitively. Explicit caller aliases are validated separately.

Types

type AggregateTerm

type AggregateTerm struct{ Column, Function, Alias string }

AggregateTerm names one explicit aggregate over an original projected column. COUNT(*) is represented separately by count; COUNT terms count non-null cells.

type Preview

type Preview struct {
	DTQL          string
	OutputColumns []string
	Scope         Scope
}

Preview is the exact validated DTQL document and its resulting projection.

func DeriveGroup

func DeriveGroup(originalDTQL string, groupColumns []string, count bool, scope Scope) (Preview, error)

DeriveGroup creates a bounded query preview grouped by selected projected columns. Count adds only an explicit COUNT(*) output; no other aggregates are inferred. Empty groupColumns is refused.

func DeriveGroupAggregates

func DeriveGroupAggregates(originalDTQL string, keys []string, count bool, terms []AggregateTerm, scope Scope) (Preview, error)

DeriveGroupAggregates preserves the chosen input scope and emits the exact, ordered key, optional COUNT(*), and explicit measure projection. Missing measure aliases use readable, collision-safe defaults; caller inputs stay intact.

func DeriveSort

func DeriveSort(originalDTQL string, terms []SortTerm, scope Scope) (Preview, error)

DeriveSort creates a bounded query preview ordered by selected projected columns. It deliberately replaces the query's final ordering and output cap.

type Scope

type Scope uint8

Scope identifies which rows a server operation transforms.

const (
	MatchingSource Scope = iota + 1
	OriginalOutput
)

type SortTerm

type SortTerm struct {
	Column     string
	Descending bool
}

SortTerm selects one projected column and direction. Earlier terms have higher priority; equal-key ordering and collation follow the query backend's tie, collation, and null semantics unless callers add explicit tie keys.

Jump to

Keyboard shortcuts

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