You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Beam JIRA Bot (Jira)" <ji...@apache.org> on 2021/09/05 17:24:01 UTC

[jira] [Updated] (BEAM-12581) Row.toString() method is throwing NullPointerException while processing a nullable map

     [ https://issues.apache.org/jira/browse/BEAM-12581?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Beam JIRA Bot updated BEAM-12581:
---------------------------------
    Labels: stale-P2  (was: )

> Row.toString() method is throwing NullPointerException while processing a nullable map
> --------------------------------------------------------------------------------------
>
>                 Key: BEAM-12581
>                 URL: https://issues.apache.org/jira/browse/BEAM-12581
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>    Affects Versions: 2.30.0
>            Reporter: Luis Muñoz
>            Priority: P2
>              Labels: stale-P2
>
> 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*:
>  
>  
> {code:java}
> @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();
> }
> {code}
> 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:
> {code:java}
> Row: union:{(testing, value), } 
> {code}
> Which has an extra comma despite the fact it is only one element in the map.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)