[ 
https://issues.apache.org/jira/browse/FLINK-41261?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rion Williams updated FLINK-41261:
----------------------------------
    Description: 
FLINK-41260 rejects ARRAY_AGG(x ORDER BY y) and JSON_ARRAY_AGG(x ORDER BY y) 
during validation, because the runtime ignored the ordering. Postgres, BigQuery 
and Snowflake support the clause.

Supporting it needs:
 * the call to resolve to Flink's ARRAY_AGG with the ORDER BY kept as the 
AggregateCall collation, instead of keeping Calcite's 
SqlLibraryOperators.ARRAY_AGG (whose ORDERED_FUNCTION syntax SymbolUtil cannot 
serialize);
 * the collation in the compiled plan, since AggregateCallJsonSerializer does 
not write it today, with a restore test;
 * an accumulator that keeps the sort keys and orders the elements on getValue, 
with retraction support for streaming. Today the accumulator holds only the 
values (the reason given in FLINK-21949).

 ** All of the above is also applicable to the JSON_ARRAY_AGG function.

  was:
FLINK-41260 rejects ARRAY_AGG(x ORDER BY y) during validation, because the 
runtime ignored the ordering. Postgres, BigQuery and Snowflake support the 
clause.

Supporting it needs:
* the call to resolve to Flink's ARRAY_AGG with the ORDER BY kept as the 
AggregateCall collation, instead of keeping Calcite's 
SqlLibraryOperators.ARRAY_AGG (whose ORDERED_FUNCTION syntax SymbolUtil cannot 
serialize);
* the collation in the compiled plan, since AggregateCallJsonSerializer does 
not write it today, with a restore test;
* an accumulator that keeps the sort keys and orders the elements on getValue, 
with retraction support for streaming. Today the accumulator holds only the 
values (the reason given in FLINK-21949).


> Support ORDER BY in ARRAY_AGG/JSON_ARRAY_AGG
> --------------------------------------------
>
>                 Key: FLINK-41261
>                 URL: https://issues.apache.org/jira/browse/FLINK-41261
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table SQL / Planner
>            Reporter: Rion Williams
>            Priority: Major
>
> FLINK-41260 rejects ARRAY_AGG(x ORDER BY y) and JSON_ARRAY_AGG(x ORDER BY y) 
> during validation, because the runtime ignored the ordering. Postgres, 
> BigQuery and Snowflake support the clause.
> Supporting it needs:
>  * the call to resolve to Flink's ARRAY_AGG with the ORDER BY kept as the 
> AggregateCall collation, instead of keeping Calcite's 
> SqlLibraryOperators.ARRAY_AGG (whose ORDERED_FUNCTION syntax SymbolUtil 
> cannot serialize);
>  * the collation in the compiled plan, since AggregateCallJsonSerializer does 
> not write it today, with a restore test;
>  * an accumulator that keeps the sort keys and orders the elements on 
> getValue, with retraction support for streaming. Today the accumulator holds 
> only the values (the reason given in FLINK-21949).
>  ** All of the above is also applicable to the JSON_ARRAY_AGG function.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to