![]() |
ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Custom type AGG_TOKEN for a provenance semimodule value, to be used in attributes that are computed as a result of aggregation. More...
Functions | |
| AGG_TOKEN | provsql.agg_token_in (CSTRING) |
| Input function for the AGG_TOKEN type (parses TEXT representation). | |
| CSTRING | provsql.agg_token_out (AGG_TOKEN) |
| Output function for the AGG_TOKEN type. | |
| TEXT | provsql.agg_token_cast (AGG_TOKEN) |
| Cast an AGG_TOKEN to its TEXT representation. | |
| UUID | provsql.agg_token_uuid (AGG_TOKEN aggtok) |
| Extract the UUID from an AGG_TOKEN (implicit cast to UUID). | |
| UUID | provsql.CAST(AGG_TOKEN AS UUID) (AGG_TOKEN) |
| Implicit PostgreSQL cast from AGG_TOKEN to UUID (delegates to agg_token_uuid()). | |
| BOOLEAN | provsql.agg_guard_holds (UUID token) |
| Deterministic truth of a Boolean guard sub-circuit over aggregate comparisons, evaluated in the actual world (all input tuples present). | |
| NUMERIC | provsql.agg_gate_value (UUID token) |
| Deterministic (actual-world) scalar value of an aggregate-carrying gate. | |
| TEXT | provsql.agg_token_value_text (UUID token) |
Recover the "value (*)" display string for an aggregation gate. | |
| NUMERIC | provsql.agg_token_to_numeric (AGG_TOKEN) |
| Cast an AGG_TOKEN to NUMERIC (extracts the aggregate value, loses provenance). | |
| DOUBLE PRECISION | provsql.agg_token_to_float8 (AGG_TOKEN) |
| Cast an AGG_TOKEN to DOUBLE PRECISION (extracts the aggregate value, loses provenance). | |
| INTEGER | provsql.agg_token_to_int4 (AGG_TOKEN) |
| Cast an AGG_TOKEN to INTEGER (extracts the aggregate value, loses provenance). | |
| bigint | provsql.agg_token_to_int8 (AGG_TOKEN) |
| Cast an AGG_TOKEN to bigint (extracts the aggregate value, loses provenance). | |
| TEXT | provsql.agg_token_to_text (AGG_TOKEN) |
| Cast an AGG_TOKEN to TEXT (extracts the aggregate value, loses provenance). | |
| CREATE | provsql.CAST (AGG_TOKEN AS NUMERIC) WITH FUNCTION agg_token_to_numeric(AGG_TOKEN) AS ASSIGNMENT |
| Assignment cast from AGG_TOKEN to NUMERIC (extracts the scalar value, dropping provenance). | |
| NUMERIC | provsql.agg_token_value (AGG_TOKEN) |
| Arithmetic on aggregates (AGG_TOKEN) Mirrors the random_variable arithmetic surface: the operators build a gate_arith over the operand provenance UUIDs (via provenance_arith, info1 = PROVSQL_ARITH_*), so the arithmetic is recorded symbolically in the circuit and can be resolved when a comparison (gate_cmp) over the result is evaluated. | |
| AGG_TOKEN | provsql.agg_token_make (UUID tok, NUMERIC val) |
| Bundle a provenance gate UUID with a running value into an AGG_TOKEN (inverse of the agg_token_uuid / agg_token_value accessors). | |
| UUID | provsql.agg_value_gate (NUMERIC v) |
| Lift a scalar NUMERIC constant into a gate_value leaf and return its UUID, so it can be a child of a gate_arith (the agg-side analogue of as_random for random_variable). | |
| AGG_TOKEN | provsql.agg_arith_make (INT op, UUID[] children, NUMERIC val) |
| Mint (or reuse) the gate_arith for an AGG_TOKEN arithmetic result and return the AGG_TOKEN carrying it. | |
| AGG_TOKEN | provsql.agg_token_plus (AGG_TOKEN a, AGG_TOKEN b) |
| AGG_TOKEN <op> AGG_TOKEN | |
| AGG_TOKEN | provsql.agg_token_minus (AGG_TOKEN a, AGG_TOKEN b) |
| AGG_TOKEN - AGG_TOKEN (gate_arith MINUS). | |
| AGG_TOKEN | provsql.agg_token_times (AGG_TOKEN a, AGG_TOKEN b) |
| AGG_TOKEN * AGG_TOKEN (gate_arith TIMES). | |
| AGG_TOKEN | provsql.agg_token_div (AGG_TOKEN a, AGG_TOKEN b) |
| AGG_TOKEN / AGG_TOKEN (gate_arith DIV). | |
| AGG_TOKEN | provsql.agg_token_neg (AGG_TOKEN a) |
| Unary -AGG_TOKEN (gate_arith NEG). | |
| AGG_TOKEN | provsql.agg_token_plus_numeric (AGG_TOKEN a, NUMERIC b) |
| AGG_TOKEN <op> NUMERIC | |
| AGG_TOKEN | provsql.agg_token_minus_numeric (AGG_TOKEN a, NUMERIC b) |
| AGG_TOKEN - NUMERIC. | |
| AGG_TOKEN | provsql.agg_token_times_numeric (AGG_TOKEN a, NUMERIC b) |
| AGG_TOKEN * NUMERIC. | |
| AGG_TOKEN | provsql.agg_token_div_numeric (AGG_TOKEN a, NUMERIC b) |
| AGG_TOKEN / NUMERIC. | |
| AGG_TOKEN | provsql.numeric_plus_agg_token (NUMERIC a, AGG_TOKEN b) |
| NUMERIC <op> AGG_TOKEN | |
| AGG_TOKEN | provsql.numeric_minus_agg_token (NUMERIC a, AGG_TOKEN b) |
| NUMERIC - AGG_TOKEN. | |
| AGG_TOKEN | provsql.numeric_times_agg_token (NUMERIC a, AGG_TOKEN b) |
| NUMERIC * AGG_TOKEN. | |
| AGG_TOKEN | provsql.numeric_div_agg_token (NUMERIC a, AGG_TOKEN b) |
| NUMERIC / AGG_TOKEN. | |
| BOOLEAN | provsql.agg_token_op_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| Operator declarations. | |
| BOOLEAN | provsql.agg_token_op_numeric (AGG_TOKEN left, NUMERIC right) |
| BOOLEAN | provsql.numeric_op_agg_token (NUMERIC left, AGG_TOKEN right) |
| AGG_TOKEN | provsql.agg_token_cond (AGG_TOKEN a, UUID cond) |
Condition a discrete aggregate's distribution on an event: "SUM(x) | C". | |
| BOOLEAN | provsql.agg_token_op_uuid (AGG_TOKEN left, UUID right) |
| AGG_TOKEN | provsql.agg_token_cond_predicate (AGG_TOKEN a, BOOLEAN predicate) |
Placeholder for "SUM(x) | (predicate)" on an AGG_TOKEN. | |
| BOOLEAN | provsql.agg_token_op_boolean (AGG_TOKEN left, BOOLEAN right) |
| AGG_TOKEN | provsql.agg_conditioned_target (AGG_TOKEN a) |
Unpack the target of a conditioned AGG_TOKEN. | |
| BOOLEAN | provsql.agg_token_comp_numeric (AGG_TOKEN a, NUMERIC b) |
| Placeholder comparison of AGG_TOKEN with NUMERIC. | |
| BOOLEAN | provsql.numeric_comp_agg_token (NUMERIC a, AGG_TOKEN b) |
| Placeholder comparison of NUMERIC with AGG_TOKEN. | |
| BOOLEAN | provsql.agg_token_lt_numeric (AGG_TOKEN left, NUMERIC right) |
| SQL operator AGG_TOKEN < NUMERIC (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.numeric_lt_agg_token (NUMERIC left, AGG_TOKEN right) |
| SQL operator NUMERIC < AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_le_numeric (AGG_TOKEN left, NUMERIC right) |
| SQL operator AGG_TOKEN <= NUMERIC (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.numeric_le_agg_token (NUMERIC left, AGG_TOKEN right) |
| SQL operator NUMERIC <= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_eq_numeric (AGG_TOKEN left, NUMERIC right) |
| SQL operator AGG_TOKEN = NUMERIC (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.numeric_eq_agg_token (NUMERIC left, AGG_TOKEN right) |
| SQL operator NUMERIC = AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_ne_numeric (AGG_TOKEN left, NUMERIC right) |
| SQL operator AGG_TOKEN <> NUMERIC (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.numeric_ne_agg_token (NUMERIC left, AGG_TOKEN right) |
| SQL operator NUMERIC <> AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_ge_numeric (AGG_TOKEN left, NUMERIC right) |
| SQL operator AGG_TOKEN >= NUMERIC (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.numeric_ge_agg_token (NUMERIC left, AGG_TOKEN right) |
| SQL operator NUMERIC >= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_gt_numeric (AGG_TOKEN left, NUMERIC right) |
| SQL operator AGG_TOKEN > NUMERIC (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.numeric_gt_agg_token (NUMERIC left, AGG_TOKEN right) |
| SQL operator NUMERIC > AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_comp_agg_token (AGG_TOKEN a, AGG_TOKEN b) |
| Placeholder comparison of two AGG_TOKEN values (the diagonal). | |
| BOOLEAN | provsql.agg_token_lt_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| SQL operator AGG_TOKEN < AGG_TOKEN (placeholder rewritten at plan time). | |
| BOOLEAN | provsql.agg_token_le_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| SQL operator AGG_TOKEN <= AGG_TOKEN (placeholder rewritten at plan time). | |
| BOOLEAN | provsql.agg_token_gt_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| SQL operator AGG_TOKEN > AGG_TOKEN (placeholder rewritten at plan time). | |
| BOOLEAN | provsql.agg_token_ge_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| SQL operator AGG_TOKEN >= AGG_TOKEN (placeholder rewritten at plan time). | |
| BOOLEAN | provsql.agg_token_eq_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| SQL operator AGG_TOKEN = AGG_TOKEN (placeholder rewritten at plan time). | |
| BOOLEAN | provsql.agg_token_ne_agg_token (AGG_TOKEN left, AGG_TOKEN right) |
| SQL operator AGG_TOKEN <> AGG_TOKEN (placeholder rewritten at plan time). | |
| BOOLEAN | provsql.agg_token_comp_text (AGG_TOKEN a, TEXT b) |
| Placeholder comparison of AGG_TOKEN with TEXT. | |
| BOOLEAN | provsql.text_comp_agg_token (TEXT a, AGG_TOKEN b) |
| Placeholder comparison of TEXT with AGG_TOKEN. | |
| BOOLEAN | provsql.agg_token_eq_text (AGG_TOKEN left, TEXT right) |
| SQL operator AGG_TOKEN = TEXT (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.text_eq_agg_token (TEXT left, AGG_TOKEN right) |
| SQL operator TEXT = AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.agg_token_ne_text (AGG_TOKEN left, TEXT right) |
| SQL operator AGG_TOKEN <> TEXT (placeholder rewritten by ProvSQL at plan time). | |
| BOOLEAN | provsql.text_ne_agg_token (TEXT left, AGG_TOKEN right) |
| SQL operator TEXT <> AGG_TOKEN (placeholder rewritten by ProvSQL at plan time). | |
Custom type AGG_TOKEN for a provenance semimodule value, to be used in attributes that are computed as a result of aggregation.
As for provenance tokens, this is simply a UUID, but this UUID is displayed in a specific way (as the result of the aggregation followed by a "(*)") to help with readability.
The TEXT output is controlled by the provsql.aggtoken_text_as_uuid GUC. By default it is off and the cell renders as "value (*)". When set to on (typical for UI layers such as ProvSQL Studio), the cell renders as the underlying UUID instead, so the caller can click through to the provenance circuit; the value side is then recovered via provsql.agg_token_value_text(UUID).
| AGG_TOKEN provsql.agg_arith_make | ( | INT | op, |
| UUID[] | children, | ||
| NUMERIC | val ) |
Mint (or reuse) the gate_arith for an AGG_TOKEN arithmetic result and return the AGG_TOKEN carrying it.
Also records the computed scalar in the gate's extra – exactly what aggregate evaluation does for agg gates – so agg_token_value_text can recover the "value (*)" display from the bare UUID (as ProvSQL Studio does for result cells under provsql.aggtoken_text_as_uuid). The gate UUID is deterministic in (op, children), so re-recording the (identical) value is idempotent.
| AGG_TOKEN provsql.agg_conditioned_target | ( | AGG_TOKEN | a | ) |
Unpack the target of a conditioned AGG_TOKEN.
For a "SUM(x) | C" whose provenance token is the two-child gate_conditioned [agg_target, condition] returns the AGG_TOKEN over agg_target (same running value); for any other AGG_TOKEN returns it unchanged. The conditioning event itself is recovered separately via rv_conditioned_prov on the token's UUID.
| NUMERIC provsql.agg_gate_value | ( | UUID | token | ) |
Deterministic (actual-world) scalar value of an aggregate-carrying gate.
Resolves the value an aggregate expression takes on the actual data – the value an AGG_TOKEN display cell carries: agg / arith gates RECORD it in extra (set by aggregate evaluation and agg_arith_make), a value gate carries its constant, a semimod wraps a value gate, a conditioned gate has its target's value, and a case gate selects the first branch whose guard holds in the actual world (per agg_guard_holds), else the default. Returns NULL when the gate is not aggregate-carrying or the value cannot be resolved (e.g. a non-NUMERIC aggregate).
| BOOLEAN provsql.agg_guard_holds | ( | UUID | token | ) |
Deterministic truth of a Boolean guard sub-circuit over aggregate comparisons, evaluated in the actual world (all input tuples present).
Guards are the shapes having_Expr_to_provenance_cmp mints: cmp gates over aggregate-valued children (comparison-operator OID in info1), times / plus combinations (AND / OR, with negation pushed into the comparison operators), and the one / zero indicators of regular (aggregate-free) conditions. Uses Kleene three-valued logic: returns NULL on any other gate shape, or when an operand's deterministic value cannot be resolved.
| TEXT provsql.agg_token_cast | ( | AGG_TOKEN | ) |
Cast an AGG_TOKEN to its TEXT representation.
| BOOLEAN provsql.agg_token_comp_agg_token | ( | AGG_TOKEN | a, |
| AGG_TOKEN | b ) |
Placeholder comparison of two AGG_TOKEN values (the diagonal).
Never actually called; lets the parser accept AGG_TOKEN <op> AGG_TOKEN (e.g. sum(x) > sum(y) on materialised tokens), which the ProvSQL rewriter lowers to a gate_cmp at plan time. Declaring this diagonal also disambiguates s = s2 (otherwise "operator is not unique", because both AGG_TOKEN -> UUID and AGG_TOKEN -> NUMERIC casts apply).
| BOOLEAN provsql.agg_token_comp_numeric | ( | AGG_TOKEN | a, |
| NUMERIC | b ) |
Placeholder comparison of AGG_TOKEN with NUMERIC.
This function is never actually called; it exists so the SQL parser accepts comparison operators between AGG_TOKEN and NUMERIC values. The ProvSQL query rewriter replaces these comparisons at plan time.
| BOOLEAN provsql.agg_token_comp_text | ( | AGG_TOKEN | a, |
| TEXT | b ) |
Placeholder comparison of AGG_TOKEN with TEXT.
This function is never actually called; it exists so the SQL parser accepts comparison operators between AGG_TOKEN and TEXT values. The ProvSQL query rewriter replaces these comparisons at plan time.
| AGG_TOKEN provsql.agg_token_cond | ( | AGG_TOKEN | a, |
| UUID | cond ) |
Condition a discrete aggregate's distribution on an event: "SUM(x) | C".
Mirrors random_variable_cond for the AGG_TOKEN carrier: returns a conditioned AGG_TOKEN that flows onward, its provenance token wrapped in the composable two-child gate_conditioned [agg_target, condition] while its running value is preserved. The moment / support dispatchers unpack it (agg_conditioned_target + rv_conditioned_prov) and route through the existing agg_raw_moment with the condition conjoined into the prov argument, so expected(SUM(x)|C) / variance(SUM(x)|C) report the conditional aggregate distribution. Nested conditioning folds.
| AGG_TOKEN provsql.agg_token_cond_predicate | ( | AGG_TOKEN | a, |
| BOOLEAN | predicate ) |
Placeholder for "SUM(x) | (predicate)" on an AGG_TOKEN.
Lets the conditioning event be a natural Boolean predicate (e.g. "SUM(x) | (SUM(x) > 5)") instead of a hand-built gate. Never executes: the planner converts the Boolean operand into a condition gate and emits agg_token_cond.
| AGG_TOKEN provsql.agg_token_div | ( | AGG_TOKEN | a, |
| AGG_TOKEN | b ) |
AGG_TOKEN / AGG_TOKEN (gate_arith DIV).
| AGG_TOKEN provsql.agg_token_div_numeric | ( | AGG_TOKEN | a, |
| NUMERIC | b ) |
AGG_TOKEN / NUMERIC.
| BOOLEAN provsql.agg_token_eq_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
SQL operator AGG_TOKEN = AGG_TOKEN (placeholder rewritten at plan time).
| BOOLEAN provsql.agg_token_eq_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
SQL operator AGG_TOKEN = NUMERIC (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.agg_token_eq_text | ( | AGG_TOKEN | left, |
| TEXT | right ) |
SQL operator AGG_TOKEN = TEXT (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.agg_token_ge_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
SQL operator AGG_TOKEN >= AGG_TOKEN (placeholder rewritten at plan time).
| BOOLEAN provsql.agg_token_ge_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
SQL operator AGG_TOKEN >= NUMERIC (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.agg_token_gt_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
SQL operator AGG_TOKEN > AGG_TOKEN (placeholder rewritten at plan time).
| BOOLEAN provsql.agg_token_gt_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
SQL operator AGG_TOKEN > NUMERIC (placeholder rewritten by ProvSQL at plan time).
| AGG_TOKEN provsql.agg_token_in | ( | CSTRING | ) |
Input function for the AGG_TOKEN type (parses TEXT representation).
| BOOLEAN provsql.agg_token_le_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
SQL operator AGG_TOKEN <= AGG_TOKEN (placeholder rewritten at plan time).
| BOOLEAN provsql.agg_token_le_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
SQL operator AGG_TOKEN <= NUMERIC (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.agg_token_lt_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
SQL operator AGG_TOKEN < AGG_TOKEN (placeholder rewritten at plan time).
| BOOLEAN provsql.agg_token_lt_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
SQL operator AGG_TOKEN < NUMERIC (placeholder rewritten by ProvSQL at plan time).
| AGG_TOKEN provsql.agg_token_make | ( | UUID | tok, |
| NUMERIC | val ) |
Bundle a provenance gate UUID with a running value into an AGG_TOKEN (inverse of the agg_token_uuid / agg_token_value accessors).
| AGG_TOKEN provsql.agg_token_minus | ( | AGG_TOKEN | a, |
| AGG_TOKEN | b ) |
AGG_TOKEN - AGG_TOKEN (gate_arith MINUS).
| AGG_TOKEN provsql.agg_token_minus_numeric | ( | AGG_TOKEN | a, |
| NUMERIC | b ) |
AGG_TOKEN - NUMERIC.
| BOOLEAN provsql.agg_token_ne_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
SQL operator AGG_TOKEN <> AGG_TOKEN (placeholder rewritten at plan time).
| BOOLEAN provsql.agg_token_ne_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
SQL operator AGG_TOKEN <> NUMERIC (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.agg_token_ne_text | ( | AGG_TOKEN | left, |
| TEXT | right ) |
SQL operator AGG_TOKEN <> TEXT (placeholder rewritten by ProvSQL at plan time).
| AGG_TOKEN provsql.agg_token_neg | ( | AGG_TOKEN | a | ) |
Unary -AGG_TOKEN (gate_arith NEG).
| BOOLEAN provsql.agg_token_op_agg_token | ( | AGG_TOKEN | left, |
| AGG_TOKEN | right ) |
Operator declarations.
| BOOLEAN provsql.agg_token_op_boolean | ( | AGG_TOKEN | left, |
| BOOLEAN | right ) |
| BOOLEAN provsql.agg_token_op_numeric | ( | AGG_TOKEN | left, |
| NUMERIC | right ) |
| BOOLEAN provsql.agg_token_op_uuid | ( | AGG_TOKEN | left, |
| UUID | right ) |
| CSTRING provsql.agg_token_out | ( | AGG_TOKEN | ) |
Output function for the AGG_TOKEN type.
Default: produces the human-friendly "value (*)" form, where value is the running aggregate state.
When the provsql.aggtoken_text_as_uuid GUC is on, returns the underlying provenance UUID instead. UI layers (notably ProvSQL Studio) flip this on per session so aggregate cells expose the circuit root UUID for click-through; the "value (*)" display string is recovered via provsql.agg_token_value_text(UUID).
Marked STABLE rather than IMMUTABLE because the chosen output shape now depends on a GUC that the same session can flip at runtime.
| AGG_TOKEN provsql.agg_token_plus | ( | AGG_TOKEN | a, |
| AGG_TOKEN | b ) |
| AGG_TOKEN provsql.agg_token_plus_numeric | ( | AGG_TOKEN | a, |
| NUMERIC | b ) |
AGG_TOKEN <op> NUMERIC
AGG_TOKEN + NUMERIC (gate_arith PLUS, constant lifted to a value gate).
| AGG_TOKEN provsql.agg_token_times | ( | AGG_TOKEN | a, |
| AGG_TOKEN | b ) |
AGG_TOKEN * AGG_TOKEN (gate_arith TIMES).
| AGG_TOKEN provsql.agg_token_times_numeric | ( | AGG_TOKEN | a, |
| NUMERIC | b ) |
AGG_TOKEN * NUMERIC.
| DOUBLE PRECISION provsql.agg_token_to_float8 | ( | AGG_TOKEN | ) |
Cast an AGG_TOKEN to DOUBLE PRECISION (extracts the aggregate value, loses provenance).
| INTEGER provsql.agg_token_to_int4 | ( | AGG_TOKEN | ) |
Cast an AGG_TOKEN to INTEGER (extracts the aggregate value, loses provenance).
| bigint provsql.agg_token_to_int8 | ( | AGG_TOKEN | ) |
Cast an AGG_TOKEN to bigint (extracts the aggregate value, loses provenance).
| NUMERIC provsql.agg_token_to_numeric | ( | AGG_TOKEN | ) |
Cast an AGG_TOKEN to NUMERIC (extracts the aggregate value, loses provenance).
| TEXT provsql.agg_token_to_text | ( | AGG_TOKEN | ) |
Cast an AGG_TOKEN to TEXT (extracts the aggregate value, loses provenance).
| UUID provsql.agg_token_uuid | ( | AGG_TOKEN | aggtok | ) |
Extract the UUID from an AGG_TOKEN (implicit cast to UUID).
| NUMERIC provsql.agg_token_value | ( | AGG_TOKEN | ) |
Arithmetic on aggregates (AGG_TOKEN) Mirrors the random_variable arithmetic surface: the operators build a gate_arith over the operand provenance UUIDs (via provenance_arith, info1 = PROVSQL_ARITH_*), so the arithmetic is recorded symbolically in the circuit and can be resolved when a comparison (gate_cmp) over the result is evaluated.
Unlike random_variable (a bare UUID), an AGG_TOKEN also carries a running scalar value, so each operator additionally computes the resulting value and bundles it back with the new gate.
Running value of an AGG_TOKEN as NUMERIC, without the provenance-loss warning the public cast emits (internal use).
| TEXT provsql.agg_token_value_text | ( | UUID | token | ) |
Recover the "value (*)" display string for an aggregation gate.
Companion helper to the provsql.aggtoken_text_as_uuid GUC. With the GUC on, an AGG_TOKEN cell prints as the underlying provenance UUID, which is convenient for tooling that wants to click through to the circuit but loses the human-readable aggregate value. This function takes such a UUID and returns the original "value (*)" string by reading the gate's extra (set by aggregate evaluation for agg gates, and by agg_arith_make for the arith gates that AGG_TOKEN arithmetic mints); for the other aggregate-carrying gates (case, conditioned, semimod, value) the value is resolved through the circuit by agg_gate_value. Returns NULL if token does not resolve to an aggregate-carrying gate.
| token | UUID of an agg gate (typically obtained from an AGG_TOKEN cell when aggtoken_text_as_uuid is on, or via a manual UUID cast otherwise). |
| UUID provsql.agg_value_gate | ( | NUMERIC | v | ) |
Lift a scalar NUMERIC constant into a gate_value leaf and return its UUID, so it can be a child of a gate_arith (the agg-side analogue of as_random for random_variable).
| CREATE provsql.CAST | ( | AGG_TOKEN AS | NUMERIC | ) |
Assignment cast from AGG_TOKEN to NUMERIC (extracts the scalar value, dropping provenance).
Assignment cast from AGG_TOKEN to TEXT (extracts value, not UUID).
Assignment cast from AGG_TOKEN to bigint.
Assignment cast from AGG_TOKEN to INTEGER.
Assignment cast from AGG_TOKEN to DOUBLE PRECISION.
ASSIGNMENT, not IMPLICIT: provenance- preserving arithmetic on aggregates is provided by the native AGG_TOKEN operators below, so an implicit NUMERIC coercion would only silently steal s + 1 away from them (and reroute it differently depending on whether provsql is in search_path). Write s::NUMERIC to opt into the lossy scalar.
| UUID provsql.CAST(AGG_TOKEN AS UUID) | ( | AGG_TOKEN | ) |
Implicit PostgreSQL cast from AGG_TOKEN to UUID (delegates to agg_token_uuid()).
| BOOLEAN provsql.numeric_comp_agg_token | ( | NUMERIC | a, |
| AGG_TOKEN | b ) |
Placeholder comparison of NUMERIC with AGG_TOKEN.
Symmetric to agg_token_comp_numeric; never actually called. The ProvSQL query rewriter replaces these comparisons at plan time.
| AGG_TOKEN provsql.numeric_div_agg_token | ( | NUMERIC | a, |
| AGG_TOKEN | b ) |
NUMERIC / AGG_TOKEN.
| BOOLEAN provsql.numeric_eq_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
SQL operator NUMERIC = AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.numeric_ge_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
SQL operator NUMERIC >= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.numeric_gt_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
SQL operator NUMERIC > AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.numeric_le_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
SQL operator NUMERIC <= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.numeric_lt_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
SQL operator NUMERIC < AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| AGG_TOKEN provsql.numeric_minus_agg_token | ( | NUMERIC | a, |
| AGG_TOKEN | b ) |
NUMERIC - AGG_TOKEN.
| BOOLEAN provsql.numeric_ne_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
SQL operator NUMERIC <> AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.numeric_op_agg_token | ( | NUMERIC | left, |
| AGG_TOKEN | right ) |
| AGG_TOKEN provsql.numeric_plus_agg_token | ( | NUMERIC | a, |
| AGG_TOKEN | b ) |
| AGG_TOKEN provsql.numeric_times_agg_token | ( | NUMERIC | a, |
| AGG_TOKEN | b ) |
NUMERIC * AGG_TOKEN.
| BOOLEAN provsql.text_comp_agg_token | ( | TEXT | a, |
| AGG_TOKEN | b ) |
Placeholder comparison of TEXT with AGG_TOKEN.
Symmetric to agg_token_comp_text; never actually called. The ProvSQL query rewriter replaces these comparisons at plan time.
| BOOLEAN provsql.text_eq_agg_token | ( | TEXT | left, |
| AGG_TOKEN | right ) |
SQL operator TEXT = AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).
| BOOLEAN provsql.text_ne_agg_token | ( | TEXT | left, |
| AGG_TOKEN | right ) |
SQL operator TEXT <> AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).