ProvSQL SQL API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
Type for the result of aggregate queries

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()).
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).
NUMERIC provsql.CAST(AGG_TOKEN AS NUMERIC) (AGG_TOKEN)
 Implicit PostgreSQL cast from AGG_TOKEN to NUMERIC (enables arithmetic on aggregates).
CREATE provsql.CAST (AGG_TOKEN AS DOUBLE PRECISION) WITH FUNCTION agg_token_to_float8(AGG_TOKEN) AS ASSIGNMENT
 Assignment cast from AGG_TOKEN to DOUBLE PRECISION.
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).

Detailed Description

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).

Function Documentation

◆ agg_token_cast()

TEXT provsql.agg_token_cast ( AGG_TOKEN )

Cast an AGG_TOKEN to its TEXT representation.

Source code
provsql.sql line 1581

◆ agg_token_comp_numeric()

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.

Source code
provsql.sql line 1673

◆ agg_token_eq_numeric()

BOOLEAN provsql.agg_token_eq_numeric ( AGG_TOKEN left,
NUMERIC right )

SQL operator AGG_TOKEN = NUMERIC (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1734

◆ agg_token_ge_numeric()

BOOLEAN provsql.agg_token_ge_numeric ( AGG_TOKEN left,
NUMERIC right )

SQL operator AGG_TOKEN >= NUMERIC (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1768

◆ agg_token_gt_numeric()

BOOLEAN provsql.agg_token_gt_numeric ( AGG_TOKEN left,
NUMERIC right )

SQL operator AGG_TOKEN > NUMERIC (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1785

◆ agg_token_in()

AGG_TOKEN provsql.agg_token_in ( CSTRING )

Input function for the AGG_TOKEN type (parses TEXT representation).

Source code
provsql.sql line 1556

◆ agg_token_le_numeric()

BOOLEAN provsql.agg_token_le_numeric ( AGG_TOKEN left,
NUMERIC right )

SQL operator AGG_TOKEN <= NUMERIC (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1717

◆ agg_token_lt_numeric()

BOOLEAN provsql.agg_token_lt_numeric ( AGG_TOKEN left,
NUMERIC right )

SQL operator AGG_TOKEN < NUMERIC (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1700

◆ agg_token_ne_numeric()

BOOLEAN provsql.agg_token_ne_numeric ( AGG_TOKEN left,
NUMERIC right )

SQL operator AGG_TOKEN <> NUMERIC (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1751

◆ agg_token_out()

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.

Source code
provsql.sql line 1576

◆ agg_token_to_float8()

DOUBLE PRECISION provsql.agg_token_to_float8 ( AGG_TOKEN )

Cast an AGG_TOKEN to DOUBLE PRECISION (extracts the aggregate value, loses provenance).

Source code
provsql.sql line 1636

◆ agg_token_to_int4()

INTEGER provsql.agg_token_to_int4 ( AGG_TOKEN )

Cast an AGG_TOKEN to INTEGER (extracts the aggregate value, loses provenance).

Source code
provsql.sql line 1641

◆ agg_token_to_int8()

bigint provsql.agg_token_to_int8 ( AGG_TOKEN )

Cast an AGG_TOKEN to bigint (extracts the aggregate value, loses provenance).

Source code
provsql.sql line 1646

◆ agg_token_to_numeric()

NUMERIC provsql.agg_token_to_numeric ( AGG_TOKEN )

Cast an AGG_TOKEN to NUMERIC (extracts the aggregate value, loses provenance).

Source code
provsql.sql line 1631

◆ agg_token_to_text()

TEXT provsql.agg_token_to_text ( AGG_TOKEN )

Cast an AGG_TOKEN to TEXT (extracts the aggregate value, loses provenance).

Source code
provsql.sql line 1651

◆ agg_token_uuid()

UUID provsql.agg_token_uuid ( AGG_TOKEN aggtok)

Extract the UUID from an AGG_TOKEN (implicit cast to UUID).

Source code
provsql.sql line 1593

◆ agg_token_value_text()

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 to the computed scalar). Returns NULL if token does not resolve to an agg gate.

Parameters
tokenUUID 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).
Source code
provsql.sql line 1620

◆ CAST()

CREATE provsql.CAST ( AGG_TOKEN AS DOUBLE PRECISION)

Assignment cast from AGG_TOKEN to DOUBLE PRECISION.

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.

◆ CAST(AGG_TOKEN AS NUMERIC)()

NUMERIC provsql.CAST(AGG_TOKEN AS NUMERIC) ( AGG_TOKEN )

Implicit PostgreSQL cast from AGG_TOKEN to NUMERIC (enables arithmetic on aggregates).

Source code
provsql.sql line 1656

◆ CAST(AGG_TOKEN AS UUID)()

UUID provsql.CAST(AGG_TOKEN AS UUID) ( AGG_TOKEN )

Implicit PostgreSQL cast from AGG_TOKEN to UUID (delegates to agg_token_uuid()).

Source code
provsql.sql line 1602

◆ numeric_comp_agg_token()

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.

Source code
provsql.sql line 1689

◆ numeric_eq_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).

Source code
provsql.sql line 1742

◆ numeric_ge_agg_token()

BOOLEAN provsql.numeric_ge_agg_token ( NUMERIC left,
AGG_TOKEN right )

SQL operator NUMERIC >= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1776

◆ numeric_gt_agg_token()

BOOLEAN provsql.numeric_gt_agg_token ( NUMERIC left,
AGG_TOKEN right )

SQL operator NUMERIC > AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1793

◆ numeric_le_agg_token()

BOOLEAN provsql.numeric_le_agg_token ( NUMERIC left,
AGG_TOKEN right )

SQL operator NUMERIC <= AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1725

◆ numeric_lt_agg_token()

BOOLEAN provsql.numeric_lt_agg_token ( NUMERIC left,
AGG_TOKEN right )

SQL operator NUMERIC < AGG_TOKEN (placeholder rewritten by ProvSQL at plan time).

Source code
provsql.sql line 1708

◆ numeric_ne_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).

Source code
provsql.sql line 1759