Help us shape the future of Go! Take the 2026 Go Developer Survey

testsrc

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package testsrc is a scan source that lies about its capabilities on purpose.

Why this exists

Predicate pushdown into a scan had a soundness bug for the whole of v0.1 and no test could have caught it, because the only source in the tree declared no predicate support at all. The branch that mishandled an inexact source was never executed. A rule whose dangerous path is unreachable from the test suite is a rule that is not tested, however green the suite looks.

So this package supplies the missing half of the contract: a source that claims Exact, Inexact, or something invalid, and then behaves accordingly — including badly. It is a DECORATOR rather than a bespoke in-memory table so that the same wrapper can be put around a real CSV or Parquet reader later and exercise the inexact path over real files.

What each mode does, and why

Inexact      returns EVERY row, ignoring keep entirely
Exact        returns exactly the rows keep accepts
Unsupported  returns every row; the engine's Filter does the work

Inexact returning everything looks lazy and is the point. "A superset of the matching rows" is the whole of what Inexact promises, and the full set is the largest legal superset — the most adversarial answer a conforming source can give. If the optimizer deleted the Filter above an inexact scan, this returns unfiltered data and the soundness test fails loudly. A source that filtered most rows would pass a broken optimizer whenever the fixture happened not to contain a surviving non-match.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inner

type Inner interface {
	plan.Source
	source.Openable
}

Inner is what this package decorates: a source that can both plan and produce.

type Source

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

Source wraps an Inner and answers ClassifyPredicates however the test says.

func New

func New(inner Inner, classify func([]expr.Node) []plan.Pushdown, keep func(*data.Batch, int) bool) *Source

New builds a decorator with full control over both halves of the lie: what the source CLAIMS (classify) and what it DOES (keep).

The two are deliberately independent. A source whose claim and behaviour are wired to the same value cannot express the case that matters most — claiming more than you deliver — and that case is exactly what the engine must survive.

func NewExact

func NewExact(inner Inner, keep func(*data.Batch, int) bool) *Source

NewExact claims every conjunct is Exact and applies keep to honour that.

keep must agree with the predicate the test filters on. That agreement is the test author's job, and stating it explicitly is better than embedding an expression evaluator here — internal/physical sits above this package, so reaching for Eval would be an import cycle, and a second evaluator written to dodge that is precisely the defect step 2's audit found four copies of.

func NewInexact

func NewInexact(inner Inner) *Source

NewInexact claims every conjunct is Inexact and filters nothing.

This is the regression test for the original bug in one constructor: if the Filter above the scan is dropped, unfiltered rows reach the user.

func (*Source) Caps

func (s *Source) Caps() plan.Caps

func (*Source) ClassifyPredicates

func (s *Source) ClassifyPredicates(preds []expr.Node) []plan.Pushdown

ClassifyPredicates delegates to the test's function verbatim, including when it returns a wrong-length or out-of-range answer. plan.ClassifyPredicates is what has to cope with that, and it cannot be tested by a wrapper that sanitises input first.

func (*Source) Describe

func (s *Source) Describe() string

func (*Source) Name

func (s *Source) Name() string

func (*Source) Open

func (s *Source) Open(ctx context.Context, spec source.ScanSpec) (source.BatchSource, error)

func (*Source) Schema

func (s *Source) Schema(ctx context.Context) (*dtype.Schema, error)

func (*Source) Specs

func (s *Source) Specs() []source.ScanSpec

Specs returns the ScanSpecs this source has been opened with, so a test can assert that a predicate or a row limit reached the reader rather than being silently compensated for above it.

Jump to

Keyboard shortcuts

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