Skip to content

0.2.43

Latest

Choose a tag to compare

@TimoKramer TimoKramer released this 29 Sep 08:40
d39c56e
An aggregate's argument must be a variable, and say so (#43)

* An aggregate's argument must be a variable, and say so

`(/ (count ?e) 2)` and `(* 100.0 (count ?e))` in :find reached
`-find-vars` with a Constant as the aggregate's last argument, and the
protocol has no implementation for one -- so the caller got the JVM's
`No implementation of method: :-find-vars of protocol: IFindVars`.

Implementing it as `[]` is the obvious fix and it is WRONG. I tried it:
the query then RUNS and yields an empty tuple, so `(* 100.0 (count ?e))`
answers `[[]]` where it should answer 200.0. That trades a loud internal
error for a silent wrong one, which is strictly worse -- an expression
over aggregates is not evaluated anywhere, so there is no answer to
give.

It raises instead, naming the constant and the shapes that do not work.
An ordinary aggregate, and one taking a constant FIRST (`(sample 5 ?e)`),
are unaffected; the test pins both.

Supporting the shape -- evaluating an expression over the aggregate
values per group -- would be a real extension, and is not this.

Found by BIRD, where a model writes the SQL shape by habit.

Claude-Session: https://claude.ai/code/session_01Y4iHBfBBVCr7GXhE6J5w5k

* Formatting: cljfmt

One blank line too many before the new deftest.

Claude-Session: https://claude.ai/code/session_01Y4iHBfBBVCr7GXhE6J5w5k