prestodb/presto

Aggregation function arbitrary should be order sensitive

開放

#21,786 建立於 2024年1月25日

 (13 則留言) (1 個反應) (0 位負責人)Java (5,240 個分叉)batch import
buggood first issue

倉庫指標

星標
 (15,558 顆星)
PR 合併指標
 (平均合併 34天 14小時) (30 天內合併 120 個 PR)

描述

Hi , We have found that arbitary aggregate function is order sensitive as the resultant value can change across runs. This happens despite setting ORDER BY as it doesnt honor the order sensitivity flag.

Aggregation functions that are marked as order sensitive allows user to use ORDER BY within the aggregation function call to specify an order of input. (https://prestodb.io/docs/current/functions/aggregate.html#functions-aggregate--page-root).

Your Environment

N/A

Expected Behavior

SELECT ARBITRARY(x ORDER BY x) from SOME_LARGE_TABLE; -- This table has column x

Should return same result across multiple runs.

Current Behavior

The above should ideally always return the same result , however the value returned is indeterminate.

Possible Solution

The arbitary aggregate function can be marked as order sensitive as shown below:

https://github.com/prestodb/presto/blob/4b458d41b8988f02c09bf9ff85e5d7bacf093b98/presto-main/src/main/java/com/facebook/presto/operator/aggregation/ArbitraryAggregationFunction.java#L171

Context

The Velox team is trying to ensure correctness of its aggregate functions, Because Presto's arbitary is not marked order_sensitive its harder to validate its Velox equivalent.

貢獻者指南