Skip to content
Advertisement

InvalidTypesException for Generic Pattern Transformation in Apache Flink

I have problem regarding Apache Flink. I want to have an abstract class that consumes a stream. However the pattern applied to this stream should be interchangeable.

JavaScript

TEventType marks the type of the event that is generated from the pattern. Every pattern must implement an interface called IEventPattern

JavaScript

The abstract class has a method called applyPatternSelectToStream()

JavaScript

The flink compiler always gives me the error

JavaScript

My class WorkPlaceConsumer extends the aforementioned abstract class to specify the desired event that is generated from the stream.

JavaScript

I already tried to implement the ResultTypeQueryable interface and tried to store the type information in the abstract class by passing the type information from the child class at runtime. I also was using .returns for the method to provide manual type information. Maybe I am just doing it wrong. Had anybody similar issues with generic transformations on streams?

Advertisement

Answer

All right I had a second look at your problem and you were right it has nothing to do with the lambda expression. The problem is that type erasure was applied to the PatternSelectFunction.

You can manually provide the return type by implementing ResultTypeQueryable interface. You can do it e.g. like that:

JavaScript

Of course it is just a proposal and I think you can improve the code ;). But you get the general idea of implementing ResultTypeQueryable interface.

Advertisement