Rindle docs and package mapSkip to main content

agg_table_name

Function agg_table_name 

Source
pub fn agg_table_name(csq: &CorrelatedSubquery) -> Box<str>
Expand description

The synthetic base-table NAME for a relationship count aggregate (§3.1): a content hash of the aggregate’s definition — child table, kind, the group key (correlation child fields), and the child where filter — so two queries with the same definition share one table (cross-query refcount on the client) while a different filter gets a different table (no (table, pk) collision). The parent correlation field is excluded: the count for a given group key is the same whichever parent joins it.

§Byte protocol (the cross-language contract the TS client must reproduce, §3.1)

FNV-1a-64 (offset 0xcbf29ce484222325, prime 0x100000001b3); integers little-endian; every string length-prefixed (u32 byte-length + UTF-8). In order: u32(child_field.len) then each s(child_field[i]); then the aggregate sub-AST identity (hash_agg_subquery) — s(table), byte(kind) (count = 1), the where (byte(0) if absent, else byte(1) + hash_condition), and u32(related.len) with each child’s correlation + recursion. Rendered "__agg_" + 16 lowercase hex digits. Only count reaches here — a relationship sum/avg is rejected before the sync path (reject_unsupported_sync_aggregate).