materialize icon indicating copy to clipboard operation
materialize copied to clipboard

Support additional aggregate functions

Open justinj opened this issue 4 years ago • 6 comments

  • [ ] bool_or
  • [ ] bool_and
  • [x] array_agg

Probably more! Please comment on this issue if you encounter others we're missing.

See here. These are aggregates that return the OR/AND of their inputs. Note that their behaviour is actually distinct from the dataflow Any and All aggregates in the presence of NULL.

justinj avatar May 26 '20 18:05 justinj

Going to generalize this to missing aggregates more broadly.

justinj avatar May 28 '20 15:05 justinj

Note that their behaviour is actually distinct from the dataflow Any and All aggregates in the presence of NULL.

But they can be determined from dataflow Any and All, right, by mapping NULL to true and false, respectively?

Ah no they can't because while they ignore NULL in their inputs, they produce NULL on empty inputs. What a world!

frankmcsherry avatar May 28 '20 15:05 frankmcsherry

We should probably just delete Any and All and require everyone to rewrite aggregates in to Sum and finish with the domain-specific logic they require.

frankmcsherry avatar May 28 '20 15:05 frankmcsherry

Related: #2813

wangandi avatar May 28 '20 17:05 wangandi

It would be nice to have list_agg here, as it could provide (I imagine) a more efficient alternative to jsonb_agg in several cases.

To be clear, I would prefer for list_agg to return a proper list, similar to array_agg, instead of the SQL2016 version that returns a string.

andrioni avatar Nov 19 '20 23:11 andrioni

@andrioni just a heads up that list_agg and array_agg just landed!

benesch avatar Aug 26 '21 02:08 benesch