I want to read records as a specific avro record in my Java API. I have tried to follow this example StorageSampleWithAvroBQ.
I have also generated an Avro class via this gradle plugin.
However, I cannot seem to make it work. Whenever I run my cloud function locally the error I get is
Caused by: java.lang.ClassCastException: class org.apache.avro.generic.GenericData$Record cannot be cast to class com.tdcx.cwfm.model.CwfmAbs (org.apache.avro.generic.GenericData$Record and com.tdcx.cwfm.model.CwfmAbs are in unnamed module of loader com.google.cloud.functions.invoker.runner.Invoker$FunctionClassLoader @7de26db8).
Kindly guide me in ensuring that I can read and process bigquery records as a specific class ( in this situation its CwfmAbs ).
Avro Schema
{"namespace": "com.tdcx.cwfm.model",
"type": "record",
"name": "CwfmAbs",
"fields": [
{"name": "BCP", "type": "string"},
{"name": "Project", "type": "string"},
{"name": "Site", "type": "string"},
{"name": "LOB", "type": "string"},
{"name": "Date",
"type": {
"type": "int",
"logicalType": "date"
}
},
{"name": "Emp_ID", "type": "string"},
{"name": "Name", "type": "string"},
{"name": "Supervisor", "type": "string"},
{"name": "Manager", "type": "string"},
{"name": "Scheduled_Hours_Less_Lunch", "type": "float"},
{"name": "Absent_Hours_Less_Lunch", "type": "float"},
{"name": "Late_Hours", "type": "float"}
.
.
.
}
