damccorm opened a new issue, #21063:
URL: https://github.com/apache/beam/issues/21063
When a row object has a beam schema containing fields of type MAP which
values are null, it will throw a NullPointerException while trying to call
Row.toString() method.
This could happen, for example, when you convert an AVRO record (which has
unions of null and map types) to Row object and then call toString() method.
*Test showing the issue*:
```
@Test(expected = NullPointerException.class)
public void
givenANullableMap_whileRowToString_thenThrowNullPointerException()
{
Schema mapSchema = map().values().stringType();
Schema nullableMapUnion =
SchemaBuilder.unionOf().nullType().and().type(mapSchema).endUnion();
Schema
recordSchema = SchemaBuilder.record("TestRecord").fields().name("union")
.type(nullableMapUnion).withDefault(null).endRecord();
GenericRecord
genericRecord = new GenericRecordBuilder(recordSchema).build();
Row rowRecord = AvroUtils.toBeamRowStrict(genericRecord,
AvroUtils.toBeamSchema(recordSchema));
String rowAsString = rowRecord.toString();
}
```
This behaviour doesn't happen with the previous implementation of the
Row.toString() method from version 2.29.0.
Additionally when you have a non null value for the map attribute, the row
representation as string in version 2.30.0 is as follow:
```
Row: union:{(testing, value), }
```
Which has an extra comma despite the fact it is only one element in the map.
Imported from Jira
[BEAM-12581](https://issues.apache.org/jira/browse/BEAM-12581). Original Jira
may contain additional context.
Reported by: LuisMi.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]