Class AvroRowDataDeserializationSchema

java.lang.Object
org.apache.flink.formats.avro.AvroRowDataDeserializationSchema
All Implemented Interfaces:
Serializable, org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.flink.table.data.RowData>, org.apache.flink.api.java.typeutils.ResultTypeQueryable<org.apache.flink.table.data.RowData>

@PublicEvolving public class AvroRowDataDeserializationSchema extends Object implements org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.flink.table.data.RowData>
Deserialization schema from Avro bytes to RowData.

Deserializes the byte[] messages into (nested) Flink RowData. It converts Avro types into types that are compatible with Flink's Table & SQL API.

Projects with Avro records containing logical date/time types need to add a JodaTime dependency.

Note: Changes in this class need to be kept in sync with the corresponding runtime class AvroRowDataSerializationSchema and schema converter AvroSchemaConverter.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.flink.api.common.serialization.DeserializationSchema

    org.apache.flink.api.common.serialization.DeserializationSchema.InitializationContext
  • Constructor Summary

    Constructors
    Constructor
    Description
    AvroRowDataDeserializationSchema(org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.avro.generic.GenericRecord> nestedSchema, AvroToRowDataConverters.AvroToRowDataConverter runtimeConverter, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo)
    Creates a Avro deserialization schema for the given logical type.
    AvroRowDataDeserializationSchema(org.apache.flink.table.types.logical.RowType rowType, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo)
    Creates an Avro deserialization schema for the given logical type.
    AvroRowDataDeserializationSchema(org.apache.flink.table.types.logical.RowType rowType, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding)
    Creates an Avro deserialization schema for the given logical type.
    AvroRowDataDeserializationSchema(org.apache.flink.table.types.logical.RowType rowType, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding, boolean legacyTimestampMapping)
    Creates an Avro deserialization schema for the given logical type.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.flink.table.data.RowData
    deserialize(byte[] message)
     
    boolean
     
    org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData>
     
    int
     
    boolean
    isEndOfStream(org.apache.flink.table.data.RowData nextElement)
     
    void
    open(org.apache.flink.api.common.serialization.DeserializationSchema.InitializationContext context)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.flink.api.common.serialization.DeserializationSchema

    deserialize
  • Constructor Details

    • AvroRowDataDeserializationSchema

      public AvroRowDataDeserializationSchema(org.apache.flink.table.types.logical.RowType rowType, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo)
      Creates an Avro deserialization schema for the given logical type.
      Parameters:
      rowType - The logical type used to deserialize the data.
      typeInfo - The TypeInformation to be used by getProducedType().
    • AvroRowDataDeserializationSchema

      public AvroRowDataDeserializationSchema(org.apache.flink.table.types.logical.RowType rowType, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding)
      Creates an Avro deserialization schema for the given logical type.
      Parameters:
      rowType - The logical type used to deserialize the data.
      typeInfo - The TypeInformation to be used by getProducedType().
      encoding - The serialization approach used to deserialize the data.
    • AvroRowDataDeserializationSchema

      public AvroRowDataDeserializationSchema(org.apache.flink.table.types.logical.RowType rowType, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo, AvroFormatOptions.AvroEncoding encoding, boolean legacyTimestampMapping)
      Creates an Avro deserialization schema for the given logical type.
      Parameters:
      rowType - The logical type used to deserialize the data.
      typeInfo - The TypeInformation to be used by getProducedType().
      encoding - The serialization approach used to deserialize the data.
      legacyTimestampMapping - Whether to use legacy timestamp mapping.
    • AvroRowDataDeserializationSchema

      public AvroRowDataDeserializationSchema(org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.avro.generic.GenericRecord> nestedSchema, AvroToRowDataConverters.AvroToRowDataConverter runtimeConverter, org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> typeInfo)
      Creates a Avro deserialization schema for the given logical type.
      Parameters:
      nestedSchema - Deserialization schema to deserialize as GenericRecord
      runtimeConverter - Converter that transforms a GenericRecord into RowData
      typeInfo - The TypeInformation to be used by getProducedType()
  • Method Details

    • open

      public void open(org.apache.flink.api.common.serialization.DeserializationSchema.InitializationContext context) throws Exception
      Specified by:
      open in interface org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.flink.table.data.RowData>
      Throws:
      Exception
    • deserialize

      public org.apache.flink.table.data.RowData deserialize(@Nullable byte[] message) throws IOException
      Specified by:
      deserialize in interface org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.flink.table.data.RowData>
      Throws:
      IOException
    • isEndOfStream

      public boolean isEndOfStream(org.apache.flink.table.data.RowData nextElement)
      Specified by:
      isEndOfStream in interface org.apache.flink.api.common.serialization.DeserializationSchema<org.apache.flink.table.data.RowData>
    • getProducedType

      public org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> getProducedType()
      Specified by:
      getProducedType in interface org.apache.flink.api.java.typeutils.ResultTypeQueryable<org.apache.flink.table.data.RowData>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object