[
https://issues.apache.org/jira/browse/FLINK-7357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16141605#comment-16141605
]
ASF GitHub Bot commented on FLINK-7357:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/4521#discussion_r135255639
--- Diff:
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/stream/sql/OverWindowITCase.scala
---
@@ -836,6 +836,52 @@ class OverWindowITCase extends
StreamingWithStateTestBase {
)
assertEquals(expected.sorted, StreamITCase.testResults.sorted)
}
+
+ @Test
+ def testHopStartEndWithHaving(): Unit = {
+ val env = StreamExecutionEnvironment.getExecutionEnvironment
+ val tEnv = TableEnvironment.getTableEnvironment(env)
+ env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
+ env.setStateBackend(getStateBackend)
+ StreamITCase.clear
+ env.setParallelism(1)
+
+ val sqlQueryHopStartEndWithHaving = "SELECT \n" +
+ " c AS k, \n" +
+ " COUNT(a) AS v, \n" +
+ " HOP_START(rowtime, INTERVAL '1' MINUTE, INTERVAL '1' MINUTE) AS
windowStart, \n" +
+ " HOP_END(rowtime, INTERVAL '1' MINUTE, INTERVAL '1' MINUTE) AS
windowEnd \n" +
+ "FROM \n" +
+ " T1 \n" +
+ "GROUP BY \n" +
+ " HOP(rowtime, INTERVAL '1' MINUTE, INTERVAL '1' MINUTE), \n" +
+ " c \n" +
+ "HAVING \n" +
+ " SUM(b) > 1 \n"
+
+ val data = Seq(
+ Left(14000005L, (1, 1L, "Hi")),
+ Left(14000000L, (2, 1L, "Hello")),
+ Left(14000002L, (3, 1L, "Hello")),
+ Right(14000010L)
+ )
+
+ val t1 = env.addSource(new EventTimeSourceFunction[(Int, Long,
String)](data))
+ .toTable(tEnv, 'a, 'b, 'c, 'rowtime.rowtime)
+
+ tEnv.registerTable("T1", t1)
+
+ val resultHopStartEndWithHaving =
tEnv.sql(sqlQueryHopStartEndWithHaving).toAppendStream[Row]
+ resultHopStartEndWithHaving.addSink(new StreamITCase.StringSink[Row])
+
+ env.execute()
+
+ val expected = List(
+ "Hello,2,1970-01-01 03:53:00.0,1970-01-01 03:54:00.0",
+ "Hi,1,1970-01-01 03:53:00.0,1970-01-01 03:54:00.0"
--- End diff --
This result is not correct. If the count is `1` and we filter for sums over
`b` larger than `1`, we should not include this result.
> HOP_START() HOP_END() does not work when using HAVING clause with GROUP BY
> HOP window
> -------------------------------------------------------------------------------------
>
> Key: FLINK-7357
> URL: https://issues.apache.org/jira/browse/FLINK-7357
> Project: Flink
> Issue Type: Bug
> Components: Table API & SQL
> Affects Versions: 1.3.1
> Reporter: Rong Rong
> Assignee: Rong Rong
>
> The following SQL does not compile:
> {code:title=invalid_having_hop_start_sql}
> SELECT
> c AS k,
> COUNT(a) AS v,
> HOP_START(rowtime, INTERVAL '1' MINUTE, INTERVAL '1' MINUTE) AS
> windowStart,
> HOP_END(rowtime, INTERVAL '1' MINUTE, INTERVAL '1' MINUTE) AS windowEnd
> FROM
> T1
> GROUP BY
> HOP(rowtime, INTERVAL '1' MINUTE, INTERVAL '1' MINUTE),
> c
> HAVING
> SUM(b) > 1
> {code}
> While individually keeping HAVING clause or HOP_START field compiles and runs
> without issue.
> more details:
> https://github.com/apache/flink/compare/master...walterddr:having_does_not_work_with_hop_start_end
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)