I am currently using version 4.4 of elephant-bird-pig library. If I try to make a tuple from a thrift object, I expect that fields that were not set in the object, are marked null in tuple. However instead default values are put into the tuple. E.g.
struct PropValueUnion {
1: optional i32 intValue,
2: optional i64 longValue,
3: optional string stringValue,
4: optional double doubleValue,
5: optional bool flag
}
the output of following should be (null,null,abc,null,null)
PropValueUnion value = new PropValueUnion();
a.setStringValue("abc");
System.out.println(ThriftToPig.newInstance(PropvalueUnion.class).getPigTuple(value));
Actual: (0,0,abc,0.0,0)
The problem is that isset information for fields is being lost during the conversion to tuple. Was it done deliberately and is there any workaround for this problem?
That's right. Whether or not an optional field is set can be detected by checking the
isset
flags.