windowparams

package
v1.0.0-alpha.17 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package windowparams is the one reading of a window slot's configuration, shared by the window engine (internal/processing and its window factories) and predict (internal/descriptor) so both refuse the same request with the same code and the same rule sentence. It decides what a slot MEANS and never computes a value.

The rules, in the order Check judges them:

  • order_by needs at least one key — except WIN_SHARE / WIN_LIFT, whose own reading (internal/shareparams) needs it only when cumulative — and every key names a field;
  • field is required on every value-bearing operator (FieldRequired) and refused on the order-only ones (FieldForbidden: row number, rank, dense rank read no value);
  • frame is refused on the operators that read none (FrameRejected), required on the ones that do (FrameRequired); a given frame is mode "rows", its bounds are >= 0, and a moving average bounds both ends;
  • the operator's params (offset, periods, the EWMA smoothing factor, the share / lift slot).

Every refusal is PULSE_WINDOW_INVALID on both sides: predict prefixes "window[i] (TYPE): ", the engine "TYPE: ". Predict reports every refusal Check returns; the engine raises the first.

Window types this package does not table (an embedder's extension window) are judged on the type-neutral rules only: order_by, its keys, and a given frame's mode and bounds.

Leaf: stdlib + the public errors / types packages + paramread and the two operator-specific leaves (ewmaparams, shareparams).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldForbidden

func FieldForbidden(t types.WindowType) bool

FieldForbidden reports whether a window of type t refuses a field.

func FieldRequired

func FieldRequired(t types.WindowType) bool

FieldRequired reports whether a window of type t reads a value field (and so refuses a slot without one).

func FrameRejected

func FrameRejected(t types.WindowType) bool

FrameRejected reports whether a window of type t with a frame is refused (WIN_SHARE / WIN_LIFT included: their reading refuses it).

func FrameRequired

func FrameRequired(t types.WindowType) bool

FrameRequired reports whether a window of type t without a frame is refused.

func Lag

func Lag(w *types.Window) (LagSpec, *Refusal)

Lag reads a WIN_LAG / WIN_LEAD slot's params.

Types

type LagSpec

type LagSpec struct {
	// Offset is how many rows back (lag) or forward (lead); default 1.
	Offset int
	// HasDefault reports a non-null params.default; Default is its value,
	// emitted where the offset falls outside the partition.
	HasDefault bool
	Default    any
}

LagSpec is the resolved meaning of a WIN_LAG / WIN_LEAD slot's params.

type Refusal

type Refusal struct {
	Op      types.WindowType
	Message string
	Details map[string]any
}

Refusal is one violated rule: Message is the operator-neutral sentence (callers prefix their own context) and Details the offending values.

func Check

func Check(w *types.Window) []*Refusal

Check returns every rule w breaks, in judging order; nil for a valid slot. A nil w is valid (the engine skips it).

func First

func First(w *types.Window) *Refusal

First returns the first refusal Check finds for w, or nil — the one the engine raises.

func Periods

func Periods(w *types.Window) (int, *Refusal)

Periods reads a WIN_PCT_CHANGE / WIN_DELTA slot's lookback distance; default 1.

func (*Refusal) Coded

func (r *Refusal) Coded() *errors.CodedError

Coded returns the refusal as the engine raises it: PULSE_WINDOW_INVALID, prefixed with the operator name.

func (*Refusal) Error

func (r *Refusal) Error() string

Error renders the refusal for callers that wrap it.

Jump to

Keyboard shortcuts

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