datalog: group-by-via-aggregate-in-rule test (216/216)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s

This commit is contained in:
2026-05-08 10:22:03 +00:00
parent 7a64be22d8
commit de734b27b8
3 changed files with 22 additions and 6 deletions

View File

@@ -227,6 +227,22 @@
(list {:L (list)}))
;; Aggregate vs single distinct.
;; Group-by via aggregate-in-rule-body. Per-user friend count
;; over a friends relation. The U var is bound by the prior
;; positive lit u(U) so the aggregate counts only U-rooted
;; friends per group.
(dl-at-test-set! "group-by per-user friend count"
(dl-query
(dl-program
"u(alice). u(bob). u(carol).
f(alice, x). f(alice, y). f(bob, x).
counts(U, N) :- u(U), count(N, X, f(U, X)).")
(list (quote counts) (quote U) (quote N)))
(list
{:U (quote alice) :N 2}
{:U (quote bob) :N 1}
{:U (quote carol) :N 0}))
;; Stratification: recursion through aggregation is rejected.
(dl-at-test! "agg recursion rejected"
(dl-at-throws?