Good day,
Kindly refer to this github discussion for your reference :
https://github.com/davidmc24/gradle-avro-plugin/discussions/230#discussion-5176454
I am streaming data to BigQuery tables via BigQuery Read/Write API and I am
encountering issues with deserialization. I am implementing the SpecificRecord
given my avro generated class using gradle-avro plugin found in the link above.
I have attached my avro schema and the generated class for your reference.
Code snippet :
BinaryDecoder decoder = null;
decoder = DecoderFactory.get().binaryDecoder(
avroRows.getSerializedBinaryRows().toByteArray(),
decoder);
CwfmAbsRaw read = datumReader.read(null, decoder);
Result :
{
"BCP": "\u0006",
"Project":
"TO\u0002\nClean\u0002\fManila\u0002\u0010Diversey\u0002??\u0002\u0002\n46045\u0002(B",
"Site": "itzcel A. Biongcog\u0002 Shahreza Baynosa\u0002*Cristian-ding Berso",
"LOB": "a\u0002\u0000\u0000\u0000\u0000\u0000\u0000
@\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
"Date": "1970-01-01",
"Emp_ID": "\u0000",
"Name": "",
"Supervisor": "",
"Manager": "",
"Scheduled_Hours_Less_Lunch": 4.243991582e-314,
"Absent_Hours_Less_Lunch": 1.086461844974e-311,
"Late_Hours": 2.781342323134e-309,
"Undertime_Hours": 4.778309726736481e-299,
"No_Call_No_Show_Hours_Less_Lunch": 0,
"Absent___Covid_PUI": 1e-323,
"PTO_Hours_Less_Lunch": 2.53e-321,
"LOA___Medical": 6.4758e-319,
"LOA___Covid_Related": 1.6578092e-316,
"LOA___ISP": 4.243991582e-314,
"LOA___Personal": 1.086461844974e-311,
"LOA_Hours_Less_Lunch": 2.781342323134e-309,
"ML_Hours_Less_Lunch": 4.778309726736481e-299,
"PL_Hours_Less_Lunch": 0,
"BL_Hrs_Less_Lunch": 1e-323,
"Single_Parent_Leave_Hours_Less_Lunch": 2.53e-321,
"Preventive_Suspension_Hrs_Less_Lunch": 1.3681245673789177e+87,
"Overtime_Hours": 1.5059339225139604e+161,
"Voluntary_Time_Off_Hours": 1.7122742000744298e+214,
"RTWO": 1.1449004108473628e+243,
"System_Issue": 5.579440030482586e-299,
"Absent_Hours_Less_Lunch_Reason": "46189"
}
As you can see, the string fields and double fields have weird and incorrect
values.
When I tried to use the JsonDecoder,
JsonDecoder deoder1 = DecoderFactory.get().jsonDecoder(
CwfmAbs.getClassSchema(), new
String(avroRows.getSerializedBinaryRows().toByteArray()));
the error is :
"Unrecognized header bytes: 0x02 0x06"
Finally, when I use the GenericRecord implementation, it is mapped correctly
but it is a hassle to work with. Can you help me on this?