[
https://issues.apache.org/jira/browse/FLINK-24168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17411104#comment-17411104
]
JING ZHANG commented on FLINK-24168:
------------------------------------
[~Leonard Xu] Thanks for response.
It's a good solution if we could determine the return type eagerly by
_TypeInference_ before transfer the _SQL_ to _RelNode._ But *MATCH_ROWTIME()*
is a no-args function. We have to deal with WindowJoin/IntervalJoin/or other
RelNodes which could contain more than one Rowtime attribute, we have to take
those into consideration when get the rowtime field from the input type.
I agree with you that *MATCH_ROWTIME(rowtime)* is a good option.
About compatibility, how about keep *MATCH_ROWTIME()* version with no-args
function at the same time. And add a check to throw an exception and suggest to
pass in time attribute field if we found `MATCH_ROWTIME` input row type is LTZ.
So that we could not effect the user case which does not use LTZ timestamp.
WDYT [~Leonard Xu]
> Rowtime type is not correct for windowTableFunction or OverAggregate follows
> after Match because the output type does not updated after input rowtime
> attribute changed from rowtime to rowtime_ltz
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: FLINK-24168
> URL: https://issues.apache.org/jira/browse/FLINK-24168
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 1.14.0
> Reporter: JING ZHANG
> Assignee: JING ZHANG
> Priority: Blocker
> Labels: pull-request-available
> Fix For: 1.14.0
>
>
> Rowtime type is not correct for windowTableFunction or OverAggregate on Match
> because the output type does not updated after input rowtime attribute
> changed from rowtime to rowtime_ltz in `RelTimeIndicator`.
> The bug could be reproduced by the following two cases:
> {code:java}
> @Test
> def testWindowTVFOnMatchRecognizeOnRowtimeLTZ(): Unit = {
> val sqlQuery =
> s"""
> |SELECT
> | *
> |FROM Ticker
> |MATCH_RECOGNIZE (
> | PARTITION BY symbol
> | ORDER BY ts_ltz
> | MEASURES
> | A.price as price,
> | A.tax as tax,
> | MATCH_ROWTIME() as matchRowtime
> | ONE ROW PER MATCH
> | PATTERN (A)
> | DEFINE
> | A AS A.price > 0
> |) AS T
> |""".stripMargin
> val table = util.tableEnv.sqlQuery(sqlQuery)
> util.tableEnv.registerTable("T", table)
> val sqlQuery1 =
> s"""
> |SELECT *
> |FROM TABLE(TUMBLE(TABLE T, DESCRIPTOR(matchRowtime), INTERVAL '3'
> second))
> |""".stripMargin
> util.verifyRelPlanWithType(sqlQuery1)
> }
> @Test
> def testOverWindowOnMatchRecognizeOnRowtimeLTZ(): Unit = {
> val sqlQuery =
> s"""
> |SELECT
> | *
> |FROM Ticker
> |MATCH_RECOGNIZE (
> | PARTITION BY symbol
> | ORDER BY ts_ltz
> | MEASURES
> | A.price as price,
> | A.tax as tax,
> | MATCH_ROWTIME() as matchRowtime
> | ONE ROW PER MATCH
> | PATTERN (A)
> | DEFINE
> | A AS A.price > 0
> |) AS T
> |""".stripMargin
> val table = util.tableEnv.sqlQuery(sqlQuery)
> util.tableEnv.registerTable("T", table)
> val sqlQuery1 =
> """
> |SELECT
> | symbol,
> | price,
> | tax,
> | matchRowtime,
> | SUM(price) OVER (
> | PARTITION BY symbol ORDER BY matchRowtime RANGE UNBOUNDED
> PRECEDING) as price_sum
> |FROM T
> """.stripMargin
> util.verifyRelPlanWithType(sqlQuery1)
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)