[ https://issues.apache.org/jira/browse/FLINK-22313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jark Wu closed FLINK-22313. --------------------------- Fix Version/s: 1.14.0 Resolution: Fixed Fixed in master: 3c342c93ea56a326e13fd3caf48b6a46e6604de7 > Redundant CAST in plan when selecting window start and window end in window > agg > ------------------------------------------------------------------------------- > > Key: FLINK-22313 > URL: https://issues.apache.org/jira/browse/FLINK-22313 > Project: Flink > Issue Type: Bug > Components: Table SQL / API > Affects Versions: 1.13.0 > Reporter: Caizhi Weng > Assignee: Jark Wu > Priority: Major > Labels: pull-request-available > Fix For: 1.14.0 > > > Add the following test case to > {{org.apache.flink.table.planner.plan.stream.sql.agg.WindowAggregateTest}} to > reproduce this bug. > {code:scala} > @Test > def testSessionFunction(): Unit = { > val sql = > """ > |SELECT > | COUNT(*), > | SESSION_START(proctime, INTERVAL '15' MINUTE), > | SESSION_END(proctime, INTERVAL '15' MINUTE) > |FROM MyTable > | GROUP BY SESSION(proctime, INTERVAL '15' MINUTE) > """.stripMargin > util.verifyExecPlan(sql) > } > {code} > The produced plan is > {code} > Calc(select=[EXPR$0, CAST(w$start) AS EXPR$1, CAST(w$end) AS EXPR$2]) > +- GroupWindowAggregate(window=[SessionGroupWindow('w$, proctime, 900000)], > properties=[w$start, w$end, w$proctime], select=[COUNT(*) AS EXPR$0, > start('w$) AS w$start, end('w$) AS w$end, proctime('w$) AS w$proctime]) > +- Exchange(distribution=[single]) > +- Calc(select=[proctime]) > +- WatermarkAssigner(rowtime=[rowtime], watermark=[(rowtime - > 1000:INTERVAL SECOND)]) > +- Calc(select=[PROCTIME() AS proctime, rowtime]) > +- TableSourceScan(table=[[default_catalog, default_database, > MyTable, project=[rowtime]]], fields=[rowtime]) > {code} > This is because the nullability indicated by > {{PlannerWindowStart#getResultType}} and > {{SqlGroupedWindowFunction#WindowStartEndReturnTypeInference}} are different. > Actually time attribute and window start / end should always be not null. -- This message was sent by Atlassian Jira (v8.3.4#803005)