[ 
https://issues.apache.org/jira/browse/FLINK-34702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17828590#comment-17828590
 ] 

Jacky Lau commented on FLINK-34702:
-----------------------------------

 we have three proposed solutions :

{*}Solution 1{*}: Add a switch parameter, enabled by default. When a 
compilation error occurs, the switch is turned off based on the error message. 
However, this is noticeable by the user.

{*}Solution 2{*}: Make the deduplication operator support changelog messages. 
Currently, the deduplication operator is divided into eight combinations: 
processing time / event time, first row / last row, mini-batch / 
non-mini-batch. Supporting changelog would effectively double these 
combinations to sixteen, significantly complicating the code logic. 
Furthermore, taking processing time's first row as an example, if changelog is 
supported, it would require recording all historical data, which could severely 
degrade performance. Additionally, the deduplication operator is essentially a 
special case of the Rank operator, but simply adapting the logic to use Rank 
isn't feasible either, as the Rank operator currently does not support 
mini-batch. This change would be imperceptible to users.

{*}Solution 3{*}: An improvement over Solution 1, since the logical to physical 
stage cannot detect whether there are changelog, the transformation could be 
done during the physical rewrite phase. This phase comes after the 
FlinkChangelogModeInferenceProgram.

 

After discussion with [~lincoln.86xy] offline, we agree with *Solution 3*

> Rank should not convert to StreamExecDuplicate when the input is not insert 
> only
> --------------------------------------------------------------------------------
>
>                 Key: FLINK-34702
>                 URL: https://issues.apache.org/jira/browse/FLINK-34702
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.20.0
>            Reporter: Jacky Lau
>            Priority: Major
>             Fix For: 1.20.0
>
>
> {code:java}
> @Test
> def testSimpleFirstRowOnBuiltinProctime1(): Unit = {
>   val sqlQuery =
>     """
>       |SELECT *
>       |FROM (
>       |  SELECT *,
>       |    ROW_NUMBER() OVER (PARTITION BY a ORDER BY PROCTIME() ASC) as 
> rowNum
>       |  FROM (select a, count(b) as b from MyTable group by a)
>       |)
>       |WHERE rowNum = 1
>     """.stripMargin
>   util.verifyExecPlan(sqlQuery)
> } {code}
> Exception:
> org.apache.flink.table.api.TableException: StreamPhysicalDeduplicate doesn't 
> support consuming update changes which is produced by node 
> GroupAggregate(groupBy=[a], select=[a, COUNT(b) AS b])
> because the StreamPhysicalDeduplicate can not consuming update changes now 
> while StreamExecRank can.
> so we should not convert the FlinkLogicalRank to StreamPhysicalDeduplicate in 
> this case. and we can defer whether input contains update change in the 
> "optimize the physical plan" phase. 
> so we can add an option to solve it. and when the StreamPhysicalDeduplicate 
> can support consuming update changes , we can deprecate it



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to