What happened?
In order to convert an avro GenericRecord to a Row, the org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils#toBeamRowStrict(org.apache.avro.generic.GenericRecord, org.apache.beam.sdk.schemas.Schema) method can be used. This delegates to convertAvroFieldStrict that has hardcoded the resolution of a few avro logical types (LogicalTypes.Decimal, LogicalTypes.TimestampMillis, LogicalTypes.Date) and supports only a few hardcoded source types.
However this does not work for many cases where the generic record contains fields of other types. For example, the Avro classes created with the avro-maven-plugin use the specific types (i.e. LogicalTypes.Decimal is directly stored in memory as a BigDecimal, not as a ByteBuffer).
Avro has GenericData as a way to carry logical type conversions, so the idea here is that we can actually:
- support all logical types defined by avro
- support generic records containing any custom type, as long as an appropriate conversion is also given (via
GenericData) to convert this to a primitive type. this will in turn also guarantee that SpecificRecords (SpecificRecordBase subclasses GenericRecord) are supported
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components
What happened?
In order to convert an avro
GenericRecordto aRow, theorg.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils#toBeamRowStrict(org.apache.avro.generic.GenericRecord, org.apache.beam.sdk.schemas.Schema)method can be used. This delegates toconvertAvroFieldStrictthat has hardcoded the resolution of a few avro logical types (LogicalTypes.Decimal,LogicalTypes.TimestampMillis,LogicalTypes.Date) and supports only a few hardcoded source types.However this does not work for many cases where the generic record contains fields of other types. For example, the Avro classes created with the
avro-maven-pluginuse the specific types (i.e.LogicalTypes.Decimalis directly stored in memory as aBigDecimal, not as aByteBuffer).Avro has
GenericDataas a way to carry logical type conversions, so the idea here is that we can actually:GenericData) to convert this to a primitive type. this will in turn also guarantee thatSpecificRecords (SpecificRecordBasesubclassesGenericRecord) are supportedIssue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components