1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: BUSL-1.1
//! Partial-index predicate: parse once, evaluate per row.
//!
//! A partial index declared as `CREATE INDEX ... WHERE <expr>` is
//! populated only with rows where `<expr>` evaluates to true. The
//! predicate text travels over the wire (see
//! [`crate::bridge::physical_plan::RegisteredIndex::predicate`]) and
//! gets parsed once when the Data Plane installs the index via
//! `DocumentOp::Register` or runs the initial backfill.
//!
//! Parsing reuses `nodedb_query::expr_parse::parse_generated_expr`,
//! the same entry point CHECK constraints use. Evaluation reuses
//! `SqlExpr::eval` against a `Value::Object` built from the document's
//! fields. SQL three-valued logic: only `Bool(true)` counts — `NULL`,
//! `Bool(false)`, and anything else treat the row as excluded. This
//! matches Postgres partial-index semantics (`WHERE` passes only when
//! the predicate is explicitly true, unlike CHECK which also accepts
//! NULL).
use SqlExpr;
use expr_parse;
use Value;
/// A parsed partial-index predicate, ready for per-row evaluation.