interp

package
v0.1.20 Latest Latest
Warning

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

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

Documentation

Overview

Package interp is the reference interpreter for the committed read-path subset of the relalg IR. It implements docs/design/ir-semantics.md verbatim and serves as the oracle for the cross-provider differential conformance suite (internal/conformance). It is not a performance reference.

Index

Constants

This section is empty.

Variables

View Source
var ErrIncomparable = errors.New("interp: incomparable values")

ErrIncomparable is returned when two non-NULL values of incompatible types are compared. The conformance fixture is typed, so this always indicates a corpus or interpreter bug rather than a data condition.

View Source
var ErrJoinCardinality = errors.New("interp: a join matched more than one row")

ErrJoinCardinality is returned when a join matches more than one row of its right side, which the IR rules out (it joins on a key).

View Source
var ErrUnknownColumn = errors.New("interp: unknown column")

ErrUnknownColumn is returned when an expression references a column the input relation does not have.

View Source
var ErrUnknownRelation = errors.New("interp: unknown relation")

ErrUnknownRelation is returned when a Scan references a table not present in the DB.

View Source
var ErrUnsupported = errors.New("interp: unsupported expression")

ErrUnsupported is returned for IR nodes outside the committed read-path subset (writes, procedures).

Functions

This section is empty.

Types

type DB

type DB map[string]Table

DB maps relation names to tables. Schema qualifiers are ignored: the conformance fixture lives in a single schema.

type Result

type Result struct {
	Cols []string
	Rows [][]any
}

Result is an evaluated relation: column names and positional rows.

func Eval

func Eval(db DB, e relalg.Expr) (Result, error)

Eval evaluates a committed read-path expression against db.

type Table

type Table struct {
	Cols []string
	Rows [][]any
}

Table is an in-memory base relation. Rows hold values in Cols order; cell values are nil, integers, floats, decimal strings are NOT allowed — use int64/float64/string/bool only, with numeric semantics per the spec.

type Verdict added in v0.1.20

type Verdict int

Verdict is the outcome of checking a predicate against a row of which only some columns are known.

const (
	// Fails: the predicate is FALSE or UNKNOWN whatever the other columns
	// hold, so the row does not satisfy it.
	Fails Verdict = iota
	// Holds: the predicate is TRUE whatever the other columns hold.
	Holds
	// Depends: the outcome depends on columns that are not known; the
	// residual predicate says how.
	Depends
)

func Check added in v0.1.20

func Check(p relalg.Predicate, known map[string]any) (relalg.Predicate, Verdict, error)

Check evaluates p against a row whose known columns are given (a nil value is NULL), with the semantics of docs/design/ir-semantics.md. The conditions on known columns are decided; the rest of p is returned as the residual when the verdict is Depends. A predicate the check cannot decide exactly (EXISTS, incomparable values, NULL beside unknown columns) Fails, with the reason as the error: the caller refuses the row.

Jump to

Keyboard shortcuts

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