Context
Kushtaka uses surql-py for SurrealDB access. During refactoring (#387), we found that aggregation queries (GROUP BY, GROUP ALL, count(), math::mean, math::sum) cannot be expressed with the typed CRUD helpers and must fall back to raw SurrealQL strings.
Examples that need support
# Current (raw SurrealQL):
await query('SELECT network, count() AS count FROM memory_entry GROUP BY network')
await query('SELECT math::mean(strength) AS avg FROM memory_entry GROUP ALL')
await query('SELECT count() AS total, math::sum(tokens_used) AS tokens FROM task GROUP ALL')
# Desired (typed):
await query_records('memory_entry', select=['network', count('*').as_('count')], group_by='network')
Patterns needed
GROUP BY field and GROUP ALL
count() aggregate
math::mean(), math::sum(), math::max(), math::min()
- Aliased select fields (
AS)
- Combining aggregates with filters
Context
Kushtaka uses surql-py for SurrealDB access. During refactoring (#387), we found that aggregation queries (GROUP BY, GROUP ALL, count(), math::mean, math::sum) cannot be expressed with the typed CRUD helpers and must fall back to raw SurrealQL strings.
Examples that need support
Patterns needed
GROUP BY fieldandGROUP ALLcount()aggregatemath::mean(),math::sum(),math::max(),math::min()AS)