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

Jing Zhang updated FLINK-14946:
-------------------------------
    Attachment: screenshot-5.png

> Retraction infer would result in bad plan under corner case in blink planner
> ----------------------------------------------------------------------------
>
>                 Key: FLINK-14946
>                 URL: https://issues.apache.org/jira/browse/FLINK-14946
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.9.0, 1.9.1
>            Reporter: Jing Zhang
>            Priority: Major
>         Attachments: RetractionRules1Test.scala, 
> image-2019-11-26-14-54-34-797.png, screenshot-1.png, screenshot-2.png, 
> screenshot-3.png, screenshot-4.png, screenshot-5.png
>
>
> Retractions rule would result in bad plan under some case, I simplify the 
> case like the following sql, complete test case could be found in attachments.
> {code:scala}
>   val join_sql =
>       """
>         |SELECT
>         |  ll.a AS a,
>         |  ll.b AS b,
>         |  cnt
>         |FROM (
>         | SELECT a, b, COUNT(c) AS cnt FROM l GROUP BY a, b
>         |) ll
>         |JOIN (
>         | SELECT a, b FROM r GROUP BY a, b
>         |) rr ON
>         |(ll.a = rr.a AND ll.b = rr.b)
>       """.stripMargin !image-2019-11-26-14-52-52-824.png! 
>     val sqlQuery =
>       s"""
>          |SELECT a, b_1, SUM(cnt) AS cnt
>          |FROM (
>          | SELECT *, b AS b_1 FROM (${join_sql})
>          |   UNION ALL
>          | SELECT *, 'SEA' AS b_1 FROM (${join_sql})
>          |) AS total_result
>          |GROUP BY a, b_1
>       """.stripMargin
> {code}
> The plan is :
>  !image-2019-11-26-14-54-34-797.png! 
> After retraction infer, we expect two join node in the above plan has 
> `AccRetract` asAccMode. However, AccMode of Join1 is right, accMode of Join2 
> is unexpected.
> I find  in HepPlanner, before actually apply `SetAccModeRule` to Join2, 
> HepPlanner would check if the vertex belongs to dag or not, and the result is 
> false. So `SetAccModeRule` does not actually apply to Join2.
>  !screenshot-1.png! 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to