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 ¶
- type Inner
- type Source
- func (s *Source) Caps() plan.Caps
- func (s *Source) ClassifyPredicates(preds []expr.Node) []plan.Pushdown
- func (s *Source) Describe() string
- func (s *Source) Name() string
- func (s *Source) Open(ctx context.Context, spec source.ScanSpec) (source.BatchSource, error)
- func (s *Source) Schema(ctx context.Context) (*dtype.Schema, error)
- func (s *Source) Specs() []source.ScanSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
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 ¶
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) ClassifyPredicates ¶
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.