You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: unknown aggregate / window function only errors once a row matches; returns empty on no data #414
Split out of #405 (see its comment). Whether a query with an unregistered aggregate or window function errors depends on the data. With no matching rows it returns "No results found". Once a row matches, it fails with INT-029 (aggregate) or INT-030 (window function).
Unknown predicates (QRY-007) already error in both cases.
(query [:find ?b (frob ?b :over (:order-by ?b)) :where [?a :x ?b]])
;; No results found.
(transact [[:a :x 1]])
(query [:find ?b (frob ?b :over (:order-by ?b)) :where [?a :x ?b]])
;; Error: [INT-030] unknown window function 'frob' — register it with register_aggregate() before querying
Cause
The function name is resolved only when rows are aggregated or windowed (src/query/datalog/executor.rs, Int029 near line 1495, Int030 near line 1608). The empty-result path returns before that point.
Suggested fix
Resolve every aggregate and window function in :find against the FunctionRegistry before execution, or at least before the empty-result short-circuit, the same way predicates are checked. The error should probably be a user-facing QRY-* code rather than an INT-* code, since this is a user error, not an internal one. Error codes are never removed, so keep INT-029/INT-030 registered.
Why v3.0.0
The fix turns queries that currently return an empty result into errors. #406 was moved to v3.0.0 for the same reason.
Tests
Unknown aggregate on an empty database fails.
Unknown aggregate when the :where clause matches nothing fails.
Unknown window function in both cases fails.
A registered UDF aggregate or window function on an empty database still returns an empty result.
Activity
Merge pull request #483 from project-minigraf/fix/406-414-query-valid…
adityamukho commentedon Oct 8, 2026
Fixed on
v3by #483 (ships in v3.0.0).