FlowKit icon indicating copy to clipboard operation
FlowKit copied to clipboard

Maths.

Open greenape opened this issue 4 years ago • 1 comments

Back in the day, we had the ability to do arbitrary in DB maths with, specifically, OD matrices. We removed it in #430, because it wasn't really terribly useful - OD matrices tending to be pretty small, and math with them being easy enough to do outside of the db.

I think we might want to revisit that original call, and rather than remove the ability to do math with od matrices, make the ability to do math with queries generic to all queries? This would be exceedingly useful if, for example, one wishes to compute an average of averages over a subscriber metric, where this would otherwise be a pain to do given memory etc. but can be done quite neatly in db with memoisation of parts of any sum (e.g. a running average is quite easy to achieve this was).

greenape avatar Nov 04 '21 14:11 greenape

I got some way into this for the record, but ran into issues when trying to think through how to handle types. The most obvious option, that things math'ed have a generic MathType felt like an unattractive information loss, but I couldn't see a good alternative.

Simple enough from a basic implementation point of view if one accepts generic types, and you treat column-match as the criteria for queries being op-compatible. Obviously you run into sticky territory with the logical extension, which is that you kind of want a special case for nestable spatial units (so you could do QueryAtAdmin3/QueryAtAdmin1, for example).

greenape avatar Jun 24 '22 14:06 greenape