On Fri, 2019-05-03 at 15:56 -0700, Paul Jungwirth wrote: > Hello, > > I wrote an extension to add a range_agg function with similar > behavior > to existing *_agg functions, and I'm wondering if folks would like > to > have it in core? Here is the repo: > https://github.com/pjungwir/range_agg
This seems like a very useful extension, thank you. For getting into core though, it should be a more complete set of related operations. The patch is implicitly introducing the concept of a "multirange" (in this case, an array of ranges), but it's not making the concept whole. What else should return a multirange? This patch implements the union- agg of ranges, but we also might want an intersection-agg of ranges (that is, the set of ranges that are subranges of every input). Given that there are other options here, the name "range_agg" is too generic to mean union-agg specifically. What can we do with a multirange? A lot of range operators still make sense, like "contains" or "overlaps"; but "adjacent" doesn't quite work. What about new operations like inverting a multirange to get the gaps? Do we want to continue with the array-of-ranges implementation of a multirange, or do we want a first-class multirange concept that might eliminate the boilerplate around defining all of these operations? If we have a more complete set of operators here, the flags for handling overlapping ranges and gaps will be unnecessary. Regards, Jeff Davis