avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Check Peck <comptechge...@gmail.com>
Subject How to extract String from GenericRecorcd as null instead of null string?
Date Sat, 17 Dec 2016 01:54:13 GMT
I am working with Avro and in my avro schema I have one field like this:

        "name" : "userId",
        "type" : [ "null", "string" ],
        "doc" : "some doc"

This is how I am extracting userId field from GenericRecord:

    GenericRecord payload = decoder.decode(record.value());
    String userid = String.valueOf(payload.get("userId"));
    // sometimes userid comes as null string meaning like this "null"

And because of that "null" string, my sysout prints out as false.  Is there
any way to extract userid as null instead of "null" String?

Bcoz when I check for null string it fails and if I have to accommodate
this fix, I have to add extra check with ".equals" which I want to avoid if
possible? Is there any way?

View raw message