Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-11021

ZoneOffset objects don't appear to be serialized correctly

    XMLWordPrintableJSON

Details

    Description

      In Flink 1.6.2 ZoneOffset objects are not being serialized correctly: they are turned into `null` when serialized in a Flink job. I've attached a basic sample job that illustrates the problem along with a few sbt console commands (below) that also exhibit the problem.

       

      import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
      import java.time._
      import java.time.temporal.ChronoUnit
      
      val env = StreamExecutionEnvironment.createLocalEnvironment(1)
      val UTCZoneId = ZoneId.of("UTC")
      val UTCZoneOffset = ZoneOffset.UTC
      case class MyTime(
      timestamp: ZonedDateTime,
      zoneOffset: ZoneOffset
      ) extends Serializable
      
      val now = MyTime(ZonedDateTime.now(UTCZoneId).truncatedTo(ChronoUnit.MILLIS), UTCZoneOffset)
      val mytimeTypeInfo = org.apache.flink.api.common.typeinfo.TypeInformation.of(classOf[MyTime])
      val ser = mytimeTypeInfo.createSerializer(env.getConfig)
      val out = new org.apache.flink.core.memory.ByteArrayDataOutputView()
      val serialized = ser.serialize(now, out)
      val bytes = out.toByteArray
      val in = new org.apache.flink.core.memory.ByteArrayDataInputView(bytes)
      val deserialized = ser.deserialize(in)
      println(s"""
      before serializaton: $now
      after serialization: $deserialized
      """)

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            cmroberts Christina
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: