trino

How do I enforce ordering (ORDER BY) in a custom Presto Aggregation Function

筅森魡賤 提交于 2021-01-28 01:45:34
问题 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