[
https://issues.apache.org/jira/browse/FLINK-28104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17555827#comment-17555827
]
Benchao Li commented on FLINK-28104:
------------------------------------
{quote}But for such case, not only it's not documented, but also users have no
way to call first_value(value, order) unless user modify Flink's source code
for the function FIRST_VALUE actually only accpet 1 arguments currently.
{quote}
Yes, we modified the {{{}SqlFirstLastValueAggFunction{}}}'s definition to
enable it. And I know there is no guarantee for non-documented or experimental
features.
{{FIRST_VALUE}} and {{LAST_VALUE}} should be an {{OVER}} aggregate function
instead of a general aggregate function actually. But in Flink, they are used
as general aggregate function, that's why the {{ORDER}} parameter is important.
In {{OVER}} aggregate, rows are sorted, and the result for {{FIRST_VALUE}} and
{{LAST_VALUE}} is deterministic. However, in general aggregation, there is no
order guarantees for input rows, hence {{FIRST_VALUE}} and {{LAST_VALUE}}
without {{ORDER}} will make the result non-deterministic.
In Calcite, the {{FIRST_VALUE}} and {{LAST_VALUE}} is implemented as {{OVER}}
aggregate function. In Flink, we redefined it as a general aggregate function.
I'm not opposing to remove the unexposed {{ORDER}} parameter. But, we may need
to think about the usage of {{LAST_VALUE}} and {{FIRST_VALUE}} in general
aggregation cases.
> Drop the unused order parameter in FirstValueFunction/LastValueFunction
> -----------------------------------------------------------------------
>
> Key: FLINK-28104
> URL: https://issues.apache.org/jira/browse/FLINK-28104
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / API, Table SQL / Planner
> Reporter: luoyuxia
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.16.0
>
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)