[
https://issues.apache.org/jira/browse/FLINK-18599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17158241#comment-17158241
]
Aljoscha Krettek commented on FLINK-18599:
------------------------------------------
There is a quick in the Scala compiler which causes {{windowAll}} (or
{{window()}}) to not work when the type of the {{DataStream}} is a primitive
type ({{Int}} in your case). If you change it to another type, for example
{{("foo", 1)}} (a tuple type), the code will work when you also adapt the
subsequent {{reduce()}}.
> Compile error when use windowAll and TumblingProcessingTimeWindows
> ------------------------------------------------------------------
>
> Key: FLINK-18599
> URL: https://issues.apache.org/jira/browse/FLINK-18599
> Project: Flink
> Issue Type: Bug
> Components: API / DataStream
> Affects Versions: 1.11.0
> Reporter: henvealf
> Priority: Major
>
> Code:
> {code:java}
> import org.apache.commons.lang3.StringUtils
> import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
> import
> org.apache.flink.streaming.api.windowing.assigners.{TumblingProcessingTimeWindows}
> import org.apache.flink.streaming.api.windowing.time.Time
> import org.apache.flink.streaming.api.scala._
>
> val env = StreamExecutionEnvironment.getExecutionEnvironment
> val stream = env.fromElements("a", "b", "c")
> stream
> .filter((str: String) => StringUtils.isNotEmpty(str))
> .map( _ => 1)
> .windowAll(TumblingProcessingTimeWindows.of(Time.seconds(5)))
> .reduce((a1, a2) => a1 + a2)
> .print()
> {code}
> Compile failed:
> {code:java}
> error: type mismatch;
> found :
> org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows
> required:
> org.apache.flink.streaming.api.windowing.assigners.WindowAssigner[_ >: Int, ?]
> Note: Object <: Any (and
> org.apache.flink.streaming.api.windowing.assigners.TumblingProcessingTimeWindows
> <:
> org.apache.flink.streaming.api.windowing.assigners.WindowAssigner[Object,org.apache.flink.streaming.api.windowing.windows.TimeWindow]),
> but Java-defined class WindowAssigner is invariant in type T.
> You may wish to investigate a wildcard type such as `_ <: Any`. (SLS 3.2.10)
> .windowAll(TumblingProcessingTimeWindows.of(Time.seconds(5)))
> ^
> one error found
> {code}
> What went wrong?
> Scala version: 2.11
> Flink version: 1.11
> Thanks.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)