I am writing a custom Presto Aggregation Function that produces the correct result if (and only if) the values are ordered in ascending order by the value that I am aggregating on. i.e.
The following will work:
SELECT key, MY_AGG_FUNC(value ORDER BY value ASC) FROM my_table GROUP BY key
The following will yield an incorrect result:
SELECT key, MY_AGG_FUNC(value) FROM my_table GROUP BY key
When developing the MY_AGG_FUNC
, is there a way to enforce ORDER BY value ASC
internally without relying on the caller to add it to the query?
As an alternative, is there a way to throw an Exception if the user does not specify the ORDER BY at all (or an incorrect ordering)?