tomjaguarpaw / haskell-opaleye

Other
599 stars 115 forks source link

Add support for ordered-set aggregation functions (`WITHIN GROUP`) #576

Closed shane-circuithub closed 9 months ago

shane-circuithub commented 9 months ago

This commit adds support for ordered-set aggregation functions such as mode() which use the WITHIN GROUP (ORDER BY _) syntax. However, it doesn't actually expose any public facing API for this, basically because I don't know yet what that API should be for Opaleye. There are a lot of subtle restrictions on the kinds of arguments you can pass to the ordered-set aggregation functions (e.g., percentile_disc() can take either a constant expression or one of the columns from the query we're aggregating over, but only if it's part of the GROUP BY clause) that would be hard to capture in the types that Opaleye currently uses.

What this commit does is add just enough internals for me to able to experiment with a limited API in Rel8 for ordered-set aggregation functions that might be subject to change in the future. But I don't want to add something half-baked to Opaleye's public facing API just yet.

shane-circuithub commented 9 months ago

This is based on the refactoring in #575, but no longer depends on the fixes proposed in #577 or #578.

tomjaguarpaw commented 9 months ago

Yup, all good. Likewise split up a bit and merged separately.


Due to the splitting tool all the commits get attributed to me. Sorry about that. I try to credit you on all the commits, e.g. https://github.com/tomjaguarpaw/haskell-opaleye/commit/1367e701e665e1d15395d3cf30ce3aba5ee87333. If you feel strongly about this please let me know and I'll see what I can do to fix the tool.

shane-circuithub commented 9 months ago

No worries at all, I don't care about the attribution, just happy to have this merged so I can play around with it! Thanks for being so responsive in the last week with all the PRs.

tomjaguarpaw commented 9 months ago

You're welcome. Thanks for the great PRs!