flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Federico D'Ambrosio" <federico.dambro...@smartlab.ws>
Subject Dot notation not working for accessing case classes nested fields
Date Thu, 14 Sep 2017 13:51:23 GMT
Hi,

I have the following case classes:

case class Event(instantValues: InstantValues)
case class InstantValues(speed: Int, altitude: Int, time: DateTime)


in a DataStream[Event] I'd like to perform a maxBy operation on the field
time of instantValue for each event and according to the docs here
<https://ci.apache.org/projects/flink/flink-docs-release-1.3/api/java/org/apache/flink/streaming/api/datastream/KeyedStream.html#maxBy-int->it
would be possible to use the dot notation such the following:

val events = stream
  .keyBy("otherField")
  .window(TumblingEventTimeWindows.of(Time.seconds(5)))
  .maxBy("instantValues.time")

positionToMaxBy - In case of a POJO, Scala case class, or Tuple type, the
name of the public) field on which to perform the aggregation.
Additionally, a dot can be used to drill down into nested objects, as
in "field1.fieldxy"
. Furthermore "*" can be specified in case of a basic type (which is
considered as having only one field).


Still, I'm getting the following error:

Fields 'instantValues.time' are not valid for 'package.Event(instantValues:
package.InstantValues(speed: Integer, altitude: Integer, time:
GenericType<org.joda.time.DateTime>))'

whereas if, for instance, use only "instantValues" (while implementing its
compareTo method) the aggregation works as usual.

Any idea as to why this isn't working? Am I doing something wrong?

Thanks a lot,
Federico

Mime
View raw message